@@ -57,19 +57,21 @@ def local_version_score(self):
5757 def close (self ):
5858 self ._mc .close ()
5959
60- def get_circles (self , refresh = False ):
60+ def get_circles (self ):
6161 """Return the list of DCOR Circle names
6262 """
63- clist = self ._cache_fleeting ["circles" ]
64- if not clist or refresh :
63+ # TODO: Use self._mc to extract circles
64+ clist = self ._cache_fleeting .setdefault ("circles" , [])
65+ if not clist :
6566 clist .clear ()
6667 clist += self .ai .get_circles ()
6768 return clist
6869
69- def get_collections (self , refresh = False ):
70+ def get_collections (self ):
7071 """Return the list of DCOR Collection names"""
71- clist = self ._cache_fleeting ["collections" ]
72- if not clist or refresh :
72+ # TODO: Use self._mc to extract collections
73+ clist = self ._cache_fleeting .setdefault ("collections" , [])
74+ if not clist :
7375 clist .clear ()
7476 clist += self .ai .get_collections ()
7577 return clist
@@ -80,7 +82,10 @@ def get_dataset_dict(self, ds_id):
8082 def get_datasets_user_following (self ) -> DBExtract :
8183 """Return datasets the user is following"""
8284 # TODO: Use datasets in self._mc
83- return self .ai .get_datasets_user_following ()
85+ ckey = "get_datasets_user_following"
86+ if self ._cache_fleeting .get (ckey ) is None :
87+ self ._cache_fleeting [ckey ] = self .ai .get_datasets_user_following ()
88+ return self ._cache_fleeting [ckey ]
8489
8590 def get_datasets_user_owned (self ) -> DBExtract :
8691 """Return datasets the user created"""
@@ -92,7 +97,10 @@ def get_datasets_user_owned(self) -> DBExtract:
9297 def get_datasets_user_shared (self ) -> DBExtract :
9398 """Return datasets shared with the user"""
9499 # TODO: Use datasets in self._mc
95- return self .ai .get_datasets_user_shared ()
100+ ckey = "get_datasets_user_shared"
101+ if self ._cache_fleeting .get (ckey ) is None :
102+ self ._cache_fleeting [ckey ] = self .ai .get_datasets_user_shared ()
103+ return self ._cache_fleeting [ckey ]
96104
97105 def get_users (self ):
98106 """Return the list of DCOR users"""
@@ -119,15 +127,18 @@ def search_dataset(self, query="", limit=100):
119127
120128 def update (self , reset = False , abort_event = None ):
121129 """Update the local metadata cache based on the last local timestamp"""
130+ # Clear the fleeting cache.
131+ self ._cache_fleeting .clear ()
122132 if self .remote_version_score != self .local_version_score :
123133 reset = True
124134
125135 if reset :
126136 self .local_timestamp = 0
127137 self ._mc .reset ()
128138
129- self .get_circles (refresh = True )
130- self .get_collections (refresh = True )
139+ # Call these methods now so they reflect the current database state.
140+ self .get_circles ()
141+ self .get_collections ()
131142
132143 new_timestamp = time .time ()
133144
@@ -147,4 +158,5 @@ def update(self, reset=False, abort_event=None):
147158
148159 def update_dataset (self , ds_dict ):
149160 """Update a single dataset in the database without calling `update`"""
161+ self ._cache_fleeting .clear ()
150162 self ._mc .upsert_dataset (ds_dict )
0 commit comments