Method: Moneta::Adapters::Cassandra#store

Defined in:
lib/moneta/adapters/cassandra.rb

#store(key, value, options = {}) ⇒ Object

Store value with key

Parameters:

  • key (Object)
  • value (Object)
  • options (Hash) (defaults to: {})

Options Hash (options):

  • :expires (Integer)

    Set expiration time (See Expires)

  • :raw (Boolean)

    Raw access without value transformation (See Transformer)

  • :prefix (String)

    Prefix key (See Transformer)

  • Other (Object)

    options as defined by the adapters or middleware

Returns:

  • value



120
121
122
123
124
125
126
127
128
129
130
# File 'lib/moneta/adapters/cassandra.rb', line 120

def store(key, value, options = {})
  _, wc = consistency(options)
  expires = expires_value(options)
  t = timestamp
  batch = @backend.batch do |batch|
    batch.add(@store_delete, arguments: [t, key])
    batch.add(@store, arguments: [key, value, (expires || 0).to_i, t + 1])
  end
  @backend.execute(batch, options.merge(consistency: wc))
  value
end