Class: ActiveSupport::Cache::AerospikeStore
- Inherits:
-
Store
- Object
- Store
- ActiveSupport::Cache::AerospikeStore
- Defined in:
- lib/active_support/cache/aerospike_store.rb
Constant Summary collapse
- AEROSPIKE_DEFAULT_OPTIONS =
{ :host => '127.0.0.1', :port => 3000, :ns => 'test', :set => 'cache', :bin => 'entry' }
Instance Method Summary collapse
- #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.
16 17 18 19 20 21 |
# File 'lib/active_support/cache/aerospike_store.rb', line 16 def initialize( = {}) .merge!(self.class::AEROSPIKE_DEFAULT_OPTIONS) { |key, v1| v1 } @client = .delete(:client) || Aerospike::Client.new(Aerospike::Host.new(.delete(:host), .delete(:port))) super end |
Instance Method Details
#decrement(name, amount = 1, options = nil) ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/active_support/cache/aerospike_store.rb', line 31 def decrement(name, amount = 1, = nil) = () instrument(:decrement, name, :amount => amount) do key = namespaced_key(name, ) @client.add(as_key(key, ), {[:bin] => -1 * amount}, ) end end |
#increment(name, amount = 1, options = nil) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/active_support/cache/aerospike_store.rb', line 23 def increment(name, amount = 1, = nil) = () instrument(:increment, name, :amount => amount) do key = namespaced_key(name, ) @client.add(as_key(key, ), {[:bin] => amount}, ) end end |