Show More
@@ -247,7 +247,7 b' class BaseCache:' | |||||
247 | def get_lock(self, lock_key): |
|
247 | def get_lock(self, lock_key): | |
248 | return GenerationLock(lock_key, self._locking_url) |
|
248 | return GenerationLock(lock_key, self._locking_url) | |
249 |
|
249 | |||
250 |
def evict(self, policy=None, size_limit=None) -> |
|
250 | def evict(self, policy=None, size_limit=None) -> dict: | |
251 | """ |
|
251 | """ | |
252 | Remove old items based on the conditions |
|
252 | Remove old items based on the conditions | |
253 |
|
253 | |||
@@ -257,13 +257,16 b' class BaseCache:' | |||||
257 | read the key files metadata stored. This gives us a full list of keys, cached_archived, their size and |
|
257 | read the key files metadata stored. This gives us a full list of keys, cached_archived, their size and | |
258 | access data, time creation, and access counts. |
|
258 | access data, time creation, and access counts. | |
259 |
|
259 | |||
260 |
Store that into a memory DB |
|
260 | Store that into a memory DB in order we can run different sorting strategies easily. | |
261 | Summing the size is a sum sql query. |
|
261 | Summing the size is a sum sql query. | |
262 |
|
262 | |||
263 | Then we run a sorting strategy based on eviction policy. |
|
263 | Then we run a sorting strategy based on eviction policy. | |
264 | We iterate over sorted keys, and remove each checking if we hit the overall limit. |
|
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 | policy = policy or self._eviction_policy |
|
270 | policy = policy or self._eviction_policy | |
268 | size_limit = size_limit or self._cache_size_limit |
|
271 | size_limit = size_limit or self._cache_size_limit | |
269 |
|
272 | |||
@@ -273,7 +276,7 b' class BaseCache:' | |||||
273 | policy, format_size(size_limit)) |
|
276 | policy, format_size(size_limit)) | |
274 |
|
277 | |||
275 | if select_policy is None: |
|
278 | if select_policy is None: | |
276 |
return |
|
279 | return removal_info | |
277 |
|
280 | |||
278 | db = self.get_stats_db() |
|
281 | db = self.get_stats_db() | |
279 |
|
282 | |||
@@ -327,10 +330,11 b' class BaseCache:' | |||||
327 | self.remove(archive_key) |
|
330 | self.remove(archive_key) | |
328 | removed_items += 1 |
|
331 | removed_items += 1 | |
329 | removed_size += size |
|
332 | removed_size += size | |
330 |
|
333 | removal_info['removed_items'] = removed_items | ||
|
334 | removal_info['removed_size'] = removed_size | |||
331 | log.debug('Removed %s cache archives, and reduced size by: %s', |
|
335 | log.debug('Removed %s cache archives, and reduced size by: %s', | |
332 | removed_items, format_size(removed_size)) |
|
336 | removed_items, format_size(removed_size)) | |
333 |
return remov |
|
337 | return removal_info | |
334 |
|
338 | |||
335 | def get_statistics(self): |
|
339 | def get_statistics(self): | |
336 | total_files = 0 |
|
340 | total_files = 0 |
@@ -98,7 +98,7 b' class TestArchiveCaches(object):' | |||||
98 | evict_to = 0.005 # around (5mb) |
|
98 | evict_to = 0.005 # around (5mb) | |
99 | evicted_items = d_cache.evict(size_limit=d_cache.gb_to_bytes(evict_to)) |
|
99 | evicted_items = d_cache.evict(size_limit=d_cache.gb_to_bytes(evict_to)) | |
100 | evicted = 361 |
|
100 | evicted = 361 | |
101 | assert evicted == evicted_items |
|
101 | assert {'removed_items': evicted, 'removed_size': 14039290} == evicted_items | |
102 |
|
102 | |||
103 | stats = d_cache.get_statistics() |
|
103 | stats = d_cache.get_statistics() | |
104 | assert (tries - evicted, 5405710, {}) == stats |
|
104 | assert (tries - evicted, 5405710, {}) == stats |
@@ -348,7 +348,7 b' celery.task_store_eager_result = true' | |||||
348 |
|
348 | |||
349 | ; Default cache dir for caches. Putting this into a ramdisk can boost performance. |
|
349 | ; Default cache dir for caches. Putting this into a ramdisk can boost performance. | |
350 | ; eg. /tmpfs/data_ramdisk, however this directory might require large amount of space |
|
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 | ; `sql_cache_short` cache for heavy SQL queries |
|
354 | ; `sql_cache_short` cache for heavy SQL queries | |
@@ -681,7 +681,7 b' ssh.wrapper_cmd_allow_shell = false' | |||||
681 |
|
681 | |||
682 | ; Enables logging, and detailed output send back to the client during SSH |
|
682 | ; Enables logging, and detailed output send back to the client during SSH | |
683 | ; operations. Useful for debugging, shouldn't be used in production. |
|
683 | ; operations. Useful for debugging, shouldn't be used in production. | |
684 |
ssh.enable_debug_logging = |
|
684 | ssh.enable_debug_logging = true | |
685 |
|
685 | |||
686 | ; Paths to binary executable, by default they are the names, but we can |
|
686 | ; Paths to binary executable, by default they are the names, but we can | |
687 | ; override them if we want to use a custom one |
|
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