mirror of
https://github.com/hkalexling/Mango.git
synced 2026-03-20 00:00:48 -04:00
Add config for sorted entries cache
optional
This commit is contained in:
@@ -178,10 +178,16 @@ end
|
||||
|
||||
# LRU Cache
|
||||
class SortedEntriesCache
|
||||
@@limit : Int128 = Int128.new 1024 * 1024 * 50 # 50MB
|
||||
@@limit : Int128 = Int128.new 0
|
||||
# key => entry
|
||||
@@cache = {} of String => SortedEntriesCacheEntry
|
||||
|
||||
def self.init
|
||||
enabled = Config.current.sorted_entries_cache_enable
|
||||
cache_size = Config.current.sorted_entries_cache_capacity_kbs
|
||||
@@limit = Int128.new cache_size * 1024 if enabled
|
||||
end
|
||||
|
||||
def self.gen_key(book_id : String, username : String,
|
||||
entries : Array(Entry), opt : SortOptions?)
|
||||
sig = Digest::SHA1.hexdigest (entries.map &.id).to_s
|
||||
|
||||
Reference in New Issue
Block a user