mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Cache: Some more tweaks after #7624
* Allow doing away with CacheItem Now that we have working FFI finalizers on BBs, it's mostly useless overhead. We only keep it for DocCache, because it's slightly larger, and memory pressure might put us in a do or die situation where waiting for the GC might mean an OOM kill. * Expose's LRU slot-only mode And use it for CatalogCache, which doesn't care about storage space * Make GlyphCache slots only (storage space is insignificant here, it was always going to be evicted by running out of slots). * More informative warning when we chop the cache in half
This commit is contained in:
@@ -1379,7 +1379,7 @@ function CreDocument:setupCallCache()
|
||||
if self._tag_list_call_cache then
|
||||
self._tag_list_call_cache:clear()
|
||||
else
|
||||
self._tag_list_call_cache = lru.new(10)
|
||||
self._tag_list_call_cache = lru.new(10, nil, false)
|
||||
end
|
||||
-- i.e., the only thing that follows any sort of LRU eviction logic is the *list* of tag caches.
|
||||
-- Each individual cache itself is just a simple key, value store (i.e., a hash map).
|
||||
@@ -1410,8 +1410,7 @@ function CreDocument:setupCallCache()
|
||||
self._tag_call_cache = self._tag_list_call_cache:get(tag)
|
||||
if not self._tag_call_cache then
|
||||
-- Otherwise, create it and insert it in the list cache, evicting the LRU tag cache if necessary.
|
||||
-- NOTE: We need CacheItem for its NOP onFree eviction callback.
|
||||
self._tag_call_cache = CacheItem:new{}
|
||||
self._tag_call_cache = {}
|
||||
self._tag_list_call_cache:set(tag, self._tag_call_cache)
|
||||
end
|
||||
self._current_call_cache_tag = tag
|
||||
|
||||
Reference in New Issue
Block a user