Class: ActiveSupport::Cache::AerospikeStore
- Inherits:
-
Store
- Object
- Store
- ActiveSupport::Cache::AerospikeStore
- Defined in:
- lib/active_support/cache/aerospike_store.rb
Constant Summary collapse
- DEFAULT_OPTIONS =
{ ns: 'test', set: 'rails_cache', bin: 'data', host: '127.0.0.1', port: 3000, timeout: 0.1, ttl: 60, unless_exist: false }
Instance Method Summary collapse
- #clear(options = nil) ⇒ Object
- #decrement(name, amount = 1, options = nil) ⇒ Object
- #increment(name, amount = 1, options = nil) ⇒ Object
-
#initialize(options = {}) ⇒ AerospikeStore
constructor
A new instance of AerospikeStore.
Constructor Details
#initialize(options = {}) ⇒ AerospikeStore
Returns a new instance of AerospikeStore.
17 18 19 20 21 |
# File 'lib/active_support/cache/aerospike_store.rb', line 17 def initialize( = {}) .merge!(DEFAULT_OPTIONS) { |_, user, _| user } @client = Aerospike::Client.new(.delete(:host), .delete(:port), .dup) super end |
Instance Method Details
#clear(options = nil) ⇒ Object
23 24 25 26 27 |
# File 'lib/active_support/cache/aerospike_store.rb', line 23 def clear( = nil) @client.query(Aerospike::Statement.new(@options[:ns], @options[:set])).each do |entry| @client.delete(entry.key) end end |
#decrement(name, amount = 1, options = nil) ⇒ Object
36 37 38 39 40 41 |
# File 'lib/active_support/cache/aerospike_store.rb', line 36 def decrement(name, amount = 1, = nil) = () instrument(:decrement, name, amount: amount) do @client.add(key_from(namespaced_key(name, ), ), Aerospike::Bin.new(@options[:bin], (amount * -1))) end end |
#increment(name, amount = 1, options = nil) ⇒ Object
29 30 31 32 33 34 |
# File 'lib/active_support/cache/aerospike_store.rb', line 29 def increment(name, amount = 1, = nil) = () instrument(:increment, name, amount: amount) do @client.add(key_from(namespaced_key(name, ), ), Aerospike::Bin.new(@options[:bin], amount)) end end |