##// END OF EJS Templates
archive-cache: synced with ce
super-admin -
r1252:acea161c default
parent child Browse files
Show More
@@ -247,7 +247,7 b' class BaseCache:'
247 247 def get_lock(self, lock_key):
248 248 return GenerationLock(lock_key, self._locking_url)
249 249
250 def evict(self, policy=None, size_limit=None) -> int:
250 def evict(self, policy=None, size_limit=None) -> dict:
251 251 """
252 252 Remove old items based on the conditions
253 253
@@ -257,13 +257,16 b' class BaseCache:'
257 257 read the key files metadata stored. This gives us a full list of keys, cached_archived, their size and
258 258 access data, time creation, and access counts.
259 259
260 Store that into a memory DB so we can run different sorting strategies easily.
260 Store that into a memory DB in order we can run different sorting strategies easily.
261 261 Summing the size is a sum sql query.
262 262
263 263 Then we run a sorting strategy based on eviction policy.
264 264 We iterate over sorted keys, and remove each checking if we hit the overall limit.
265 265 """
266
266 removal_info = {
267 "removed_items": 0,
268 "removed_size": 0
269 }
267 270 policy = policy or self._eviction_policy
268 271 size_limit = size_limit or self._cache_size_limit
269 272
@@ -273,7 +276,7 b' class BaseCache:'
273 276 policy, format_size(size_limit))
274 277
275 278 if select_policy is None:
276 return 0
279 return removal_info
277 280
278 281 db = self.get_stats_db()
279 282
@@ -327,10 +330,11 b' class BaseCache:'
327 330 self.remove(archive_key)
328 331 removed_items += 1
329 332 removed_size += size
330
333 removal_info['removed_items'] = removed_items
334 removal_info['removed_size'] = removed_size
331 335 log.debug('Removed %s cache archives, and reduced size by: %s',
332 336 removed_items, format_size(removed_size))
333 return removed_items
337 return removal_info
334 338
335 339 def get_statistics(self):
336 340 total_files = 0
General Comments 0
You need to be logged in to leave comments. Login now