Module: WolfCore::InMemoryStorageDataSource
- Defined in:
- lib/wolf_core/infrastructure/in_memory_storage_data_source.rb
Class Method Summary collapse
- .acquire_lock(key:, value:, expiry:) ⇒ Object
- .check_lock(key:) ⇒ Object
- .init ⇒ Object
- .instance ⇒ Object
- .release_lock(key:) ⇒ Object
- .set_non_exp_lock(key:, value:) ⇒ Object
Class Method Details
.acquire_lock(key:, value:, expiry:) ⇒ Object
13 14 15 |
# File 'lib/wolf_core/infrastructure/in_memory_storage_data_source.rb', line 13 def acquire_lock(key:, value:, expiry:) instance.set("lock:process:#{ENV['TENANT']}:#{key}", value, ex: expiry.to_i, nx: true) end |
.check_lock(key:) ⇒ Object
21 22 23 |
# File 'lib/wolf_core/infrastructure/in_memory_storage_data_source.rb', line 21 def check_lock(key:) instance.get("lock:process:#{ENV['TENANT']}:#{key}") end |
.init ⇒ Object
5 6 7 |
# File 'lib/wolf_core/infrastructure/in_memory_storage_data_source.rb', line 5 def init @@redis = Redis.new(host: ENV['REDIS_ENDPOINT']) end |
.instance ⇒ Object
9 10 11 |
# File 'lib/wolf_core/infrastructure/in_memory_storage_data_source.rb', line 9 def instance @@redis end |
.release_lock(key:) ⇒ Object
25 26 27 |
# File 'lib/wolf_core/infrastructure/in_memory_storage_data_source.rb', line 25 def release_lock(key:) instance.del("lock:process:#{ENV['TENANT']}:#{key}") end |
.set_non_exp_lock(key:, value:) ⇒ Object
17 18 19 |
# File 'lib/wolf_core/infrastructure/in_memory_storage_data_source.rb', line 17 def set_non_exp_lock(key:, value:) instance.set("lock:process:#{ENV['TENANT']}:#{key}", value, nx: true) end |