Module: Bramble::Storage::MemoryStorage

Defined in:
lib/bramble/storage/memory_storage.rb

Overview

☠ This is for single-threaded, single-process Ruby only! If you try to use this in production, you’re going to have a bad time.

Constant Summary collapse

STORAGE =
{}

Class Method Summary collapse

Class Method Details

.delete(key) ⇒ Object



24
25
26
# File 'lib/bramble/storage/memory_storage.rb', line 24

def delete(key)
  STORAGE.delete(key)
end

.get(key) ⇒ Object



20
21
22
# File 'lib/bramble/storage/memory_storage.rb', line 20

def get(key)
  STORAGE[key]
end

.increment(key) ⇒ Object



28
29
30
31
# File 'lib/bramble/storage/memory_storage.rb', line 28

def increment(key)
  STORAGE[key] ||= 0
  STORAGE[key] += 1
end

.map_keys_get(key) ⇒ Object



56
57
58
# File 'lib/bramble/storage/memory_storage.rb', line 56

def map_keys_get(key)
  STORAGE[key] || Set.new
end

.map_keys_push(key, value) ⇒ Object



51
52
53
54
# File 'lib/bramble/storage/memory_storage.rb', line 51

def map_keys_push(key, value)
  STORAGE[key] ||= Set.new
  STORAGE[key] << value
end

.map_result_get(key) ⇒ Object



38
39
40
# File 'lib/bramble/storage/memory_storage.rb', line 38

def map_result_get(key)
  STORAGE[key] || []
end

.map_result_push(key, value) ⇒ Object



33
34
35
36
# File 'lib/bramble/storage/memory_storage.rb', line 33

def map_result_push(key, value)
  STORAGE[key] ||= []
  STORAGE[key] << value
end

.reduce_result_get(storage_key) ⇒ Object



47
48
49
# File 'lib/bramble/storage/memory_storage.rb', line 47

def reduce_result_get(storage_key)
  STORAGE[storage_key] || {}
end

.reduce_result_set(storage_key, reduce_key, value) ⇒ Object



42
43
44
45
# File 'lib/bramble/storage/memory_storage.rb', line 42

def reduce_result_set(storage_key, reduce_key, value)
  STORAGE[storage_key] ||= {}
  STORAGE[storage_key][reduce_key] = value
end

.set(key, value) ⇒ Object



16
17
18
# File 'lib/bramble/storage/memory_storage.rb', line 16

def set(key, value)
  STORAGE[key] = value
end

.transactionObject



12
13
14
# File 'lib/bramble/storage/memory_storage.rb', line 12

def transaction
  yield
end