Class: Async::Background::Queue::StoreOptions
- Inherits:
-
Data
- Object
- Data
- Async::Background::Queue::StoreOptions
- Defined in:
- lib/async/background/queue/store.rb
Instance Attribute Summary collapse
-
#mmap ⇒ Object
readonly
Returns the value of attribute mmap.
-
#synchronous ⇒ Object
readonly
Returns the value of attribute synchronous.
-
#wal_autocheckpoint ⇒ Object
readonly
Returns the value of attribute wal_autocheckpoint.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(mmap:, synchronous:, wal_autocheckpoint:) ⇒ StoreOptions
constructor
A new instance of StoreOptions.
- #mmap_size ⇒ Object
- #pragma_sql ⇒ Object
- #synchronous_pragma ⇒ Object
Constructor Details
#initialize(mmap:, synchronous:, wal_autocheckpoint:) ⇒ StoreOptions
Returns a new instance of StoreOptions.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/async/background/queue/store.rb', line 17 def initialize(mmap:, synchronous:, wal_autocheckpoint:) unless mmap == true || mmap == false raise ArgumentError, "mmap must be true or false, got #{mmap.inspect}" end unless SYNCHRONOUS_LEVELS.key?(synchronous) raise ArgumentError, "synchronous must be one of #{SYNCHRONOUS_LEVELS.keys.inspect}, got #{synchronous.inspect}" end unless wal_autocheckpoint.is_a?(Integer) && WAL_AUTOCHECKPOINT_RANGE.cover?(wal_autocheckpoint) raise ArgumentError, "wal_autocheckpoint must be an Integer in #{WAL_AUTOCHECKPOINT_RANGE}, " \ "got #{wal_autocheckpoint.inspect}" end super end |
Instance Attribute Details
#mmap ⇒ Object (readonly)
Returns the value of attribute mmap
14 15 16 |
# File 'lib/async/background/queue/store.rb', line 14 def mmap @mmap end |
#synchronous ⇒ Object (readonly)
Returns the value of attribute synchronous
14 15 16 |
# File 'lib/async/background/queue/store.rb', line 14 def synchronous @synchronous end |
#wal_autocheckpoint ⇒ Object (readonly)
Returns the value of attribute wal_autocheckpoint
14 15 16 |
# File 'lib/async/background/queue/store.rb', line 14 def wal_autocheckpoint @wal_autocheckpoint end |
Class Method Details
.build(value = {}) ⇒ Object
15 |
# File 'lib/async/background/queue/store.rb', line 15 def self.build(value = {}) = value.is_a?(self) ? value : new(**DEFAULTS, **value) |
Instance Method Details
#mmap_size ⇒ Object
37 |
# File 'lib/async/background/queue/store.rb', line 37 def mmap_size = mmap ? MMAP_SIZE : 0 |
#pragma_sql ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/async/background/queue/store.rb', line 39 def pragma_sql <<~SQL PRAGMA journal_mode = WAL; PRAGMA synchronous = #{synchronous_pragma}; PRAGMA mmap_size = #{mmap_size}; PRAGMA cache_size = -16000; PRAGMA temp_store = MEMORY; PRAGMA journal_size_limit = 67108864; PRAGMA wal_autocheckpoint = #{wal_autocheckpoint}; SQL end |
#synchronous_pragma ⇒ Object
36 |
# File 'lib/async/background/queue/store.rb', line 36 def synchronous_pragma = SYNCHRONOUS_LEVELS.fetch(synchronous) |