mirror of
https://github.com/hkalexling/Mango.git
synced 2025-08-03 11:25:29 -04:00
Add config for sorted entries cache
optional
This commit is contained in:
parent
bf81a4e48b
commit
e988a8c121
@ -20,6 +20,8 @@ class Config
|
|||||||
property plugin_path : String = File.expand_path "~/mango/plugins",
|
property plugin_path : String = File.expand_path "~/mango/plugins",
|
||||||
home: true
|
home: true
|
||||||
property download_timeout_seconds : Int32 = 30
|
property download_timeout_seconds : Int32 = 30
|
||||||
|
property sorted_entries_cache_enable = false
|
||||||
|
property sorted_entries_cache_capacity_kbs = 51200
|
||||||
property disable_login = false
|
property disable_login = false
|
||||||
property default_username = ""
|
property default_username = ""
|
||||||
property auth_proxy_header_name = ""
|
property auth_proxy_header_name = ""
|
||||||
|
@ -178,10 +178,16 @@ end
|
|||||||
|
|
||||||
# LRU Cache
|
# LRU Cache
|
||||||
class SortedEntriesCache
|
class SortedEntriesCache
|
||||||
@@limit : Int128 = Int128.new 1024 * 1024 * 50 # 50MB
|
@@limit : Int128 = Int128.new 0
|
||||||
# key => entry
|
# key => entry
|
||||||
@@cache = {} of String => SortedEntriesCacheEntry
|
@@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,
|
def self.gen_key(book_id : String, username : String,
|
||||||
entries : Array(Entry), opt : SortOptions?)
|
entries : Array(Entry), opt : SortOptions?)
|
||||||
sig = Digest::SHA1.hexdigest (entries.map &.id).to_s
|
sig = Digest::SHA1.hexdigest (entries.map &.id).to_s
|
||||||
|
@ -55,6 +55,7 @@ class CLI < Clim
|
|||||||
Config.load(opts.config).set_current
|
Config.load(opts.config).set_current
|
||||||
|
|
||||||
# Initialize main components
|
# Initialize main components
|
||||||
|
SortedEntriesCache.init
|
||||||
Storage.default
|
Storage.default
|
||||||
Queue.default
|
Queue.default
|
||||||
Library.default
|
Library.default
|
||||||
|
Loading…
x
Reference in New Issue
Block a user