Module: WolfCore::InMemoryStorageOperations

Defined in:
lib/wolf_core/infrastructure/in_memory_storage_operations.rb

Instance Method Summary collapse

Instance Method Details

#acquire_lock(key:, value:, expiry:) ⇒ Object



3
4
5
# File 'lib/wolf_core/infrastructure/in_memory_storage_operations.rb', line 3

def acquire_lock(key:, value:, expiry:)
  WolfCore::InMemoryStorageDataSource.acquire_lock(key: key, value: value, expiry: expiry)
end

#add_unique_to_non_exp_lock_array(key:, value:) ⇒ Object



26
27
28
29
30
# File 'lib/wolf_core/infrastructure/in_memory_storage_operations.rb', line 26

def add_unique_to_non_exp_lock_array(key:, value:)
  arr = check_lock_json(key: key)
  arr << value unless arr.include?(value)
  set_non_exp_lock(key: key, value: arr)
end

#check_lock(key:) ⇒ Object



11
12
13
# File 'lib/wolf_core/infrastructure/in_memory_storage_operations.rb', line 11

def check_lock(key:)
  WolfCore::InMemoryStorageDataSource.check_lock(key: key)
end

#check_lock_json(key:) ⇒ Object



19
20
21
22
23
24
# File 'lib/wolf_core/infrastructure/in_memory_storage_operations.rb', line 19

def check_lock_json(key:)
  arr = check_lock(key: key)
  return JSON.parse(arr) if arr.is_a?(String)

  arr || []
end

#release_lock(key:) ⇒ Object



15
16
17
# File 'lib/wolf_core/infrastructure/in_memory_storage_operations.rb', line 15

def release_lock(key:)
  WolfCore::InMemoryStorageDataSource.release_lock(key: key)
end

#set_non_exp_lock(key:, value:) ⇒ Object



7
8
9
# File 'lib/wolf_core/infrastructure/in_memory_storage_operations.rb', line 7

def set_non_exp_lock(key:, value:)
  WolfCore::InMemoryStorageDataSource.set_non_exp_lock(key: key, value: value)
end