Skip to content

Commit 2e24225

Browse files
committed
better connection handling
1 parent 0ebcf77 commit 2e24225

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

lib/litestack/litekd.rb

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,15 @@
77

88
module Litekd
99

10-
def self.connection
11-
@@connection ||= Litekd::Connection.new(path: ":memory:")
10+
DEFAULT_OPTIONS = {
11+
path: Litesupport.root.join("kd.sqlite3"),
12+
sync: 1,
13+
mmap_size: 32 * 1024 * 1024, # 32MB
14+
}
15+
16+
def self.connection(options = {})
17+
# configuration should be loaded here
18+
@@connection ||= Litekd::Connection.new(DEFAULT_OPTIONS.merge(options))
1219
end
1320

1421
# scalars

lib/litestack/litekd/composite.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ def initialize(key, typed: :string, default: nil, expires_in: nil, after_change:
1010
@key = key.to_s
1111
@conn = Litekd.connection
1212
@typed = typed || :string
13+
@default = default
1314
@after_change = after_change
1415
@expires_in = expires_in&.to_f
15-
@default = default
1616
add(default) if default
1717
end
1818

0 commit comments

Comments
 (0)