Class: Async::Background::Queue::StoreOptions

Inherits:
Data
  • Object
show all
Defined in:
lib/async/background/queue/options.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(mmap:, synchronous:, wal_autocheckpoint:) ⇒ StoreOptions

Returns a new instance of StoreOptions.



22
23
24
25
26
27
28
# File 'lib/async/background/queue/options.rb', line 22

def initialize(mmap:, synchronous:, wal_autocheckpoint:)
  validate_mmap!(mmap)
  validate_synchronous!(synchronous)
  validate_wal_autocheckpoint!(wal_autocheckpoint)

  super
end

Instance Attribute Details

#mmapObject (readonly)

Returns the value of attribute mmap

Returns:

  • (Object)

    the current value of mmap



15
16
17
# File 'lib/async/background/queue/options.rb', line 15

def mmap
  @mmap
end

#synchronousObject (readonly)

Returns the value of attribute synchronous

Returns:

  • (Object)

    the current value of synchronous



15
16
17
# File 'lib/async/background/queue/options.rb', line 15

def synchronous
  @synchronous
end

#wal_autocheckpointObject (readonly)

Returns the value of attribute wal_autocheckpoint

Returns:

  • (Object)

    the current value of wal_autocheckpoint



15
16
17
# File 'lib/async/background/queue/options.rb', line 15

def wal_autocheckpoint
  @wal_autocheckpoint
end

Class Method Details

.build(value = {}) ⇒ Object



16
17
18
19
20
# File 'lib/async/background/queue/options.rb', line 16

def self.build(value = {})
  return value if value.is_a?(self)

  new(**DEFAULT_STORE_OPTIONS, **value)
end

Instance Method Details

#mmap_sizeObject



31
# File 'lib/async/background/queue/options.rb', line 31

def mmap_size = mmap ? MMAP_SIZE : 0

#pragma_sqlObject



33
34
35
36
37
38
39
40
41
42
43
# File 'lib/async/background/queue/options.rb', line 33

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_pragmaObject



30
# File 'lib/async/background/queue/options.rb', line 30

def synchronous_pragma = SYNCHRONOUS_LEVELS.fetch(synchronous)