Skip to content

Commit

Permalink
better connection handling
Browse files Browse the repository at this point in the history
  • Loading branch information
oldmoe committed Jun 22, 2024
1 parent 0ebcf77 commit 2e24225
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 9 additions & 2 deletions lib/litestack/litekd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/litestack/litekd/composite.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 2e24225

Please sign in to comment.