diff --git a/lib/litestack/litekd.rb b/lib/litestack/litekd.rb index 4adebdc..bb33e1f 100644 --- a/lib/litestack/litekd.rb +++ b/lib/litestack/litekd.rb @@ -7,8 +7,15 @@ module Litekd - def self.connection - @@connection ||= Litekd::Connection.new(path: ":memory:") + DEFAULT_OPTIONS = { + path: Litesupport.root.join("kd.sqlite3"), + sync: 1, + mmap_size: 32 * 1024 * 1024, # 32MB + } + + def self.connection(options = {}) + # configuration should be loaded here + @@connection ||= Litekd::Connection.new(DEFAULT_OPTIONS.merge(options)) end # scalars diff --git a/lib/litestack/litekd/composite.rb b/lib/litestack/litekd/composite.rb index c0c2d8b..9753699 100644 --- a/lib/litestack/litekd/composite.rb +++ b/lib/litestack/litekd/composite.rb @@ -10,9 +10,9 @@ def initialize(key, typed: :string, default: nil, expires_in: nil, after_change: @key = key.to_s @conn = Litekd.connection @typed = typed || :string + @default = default @after_change = after_change @expires_in = expires_in&.to_f - @default = default add(default) if default end