##// END OF EJS Templates
feat(archive-cache): added extra info on number of evicted caches
super-admin -
r5434:6da054fb 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
@@ -98,7 +98,7 b' class TestArchiveCaches(object):'
98 98 evict_to = 0.005 # around (5mb)
99 99 evicted_items = d_cache.evict(size_limit=d_cache.gb_to_bytes(evict_to))
100 100 evicted = 361
101 assert evicted == evicted_items
101 assert {'removed_items': evicted, 'removed_size': 14039290} == evicted_items
102 102
103 103 stats = d_cache.get_statistics()
104 104 assert (tries - evicted, 5405710, {}) == stats
@@ -348,7 +348,7 b' celery.task_store_eager_result = true'
348 348
349 349 ; Default cache dir for caches. Putting this into a ramdisk can boost performance.
350 350 ; eg. /tmpfs/data_ramdisk, however this directory might require large amount of space
351 cache_dir = /var/opt/rhodecode_data
351 cache_dir = %(here)s/rc-test-data
352 352
353 353 ; *********************************************
354 354 ; `sql_cache_short` cache for heavy SQL queries
@@ -681,7 +681,7 b' ssh.wrapper_cmd_allow_shell = false'
681 681
682 682 ; Enables logging, and detailed output send back to the client during SSH
683 683 ; operations. Useful for debugging, shouldn't be used in production.
684 ssh.enable_debug_logging = false
684 ssh.enable_debug_logging = true
685 685
686 686 ; Paths to binary executable, by default they are the names, but we can
687 687 ; override them if we want to use a custom one
General Comments 0
You need to be logged in to leave comments. Login now