Class: Trocla::Stores::Moneta

Inherits:
Trocla::Store show all
Defined in:
lib/trocla/stores/moneta.rb

Overview

the default moneta based store

Instance Attribute Summary collapse

Attributes inherited from Trocla::Store

#store_config, #trocla

Instance Method Summary collapse

Methods inherited from Trocla::Store

#delete, #set

Constructor Details

#initialize(config, trocla) ⇒ Moneta

Returns a new instance of Moneta.



4
5
6
7
8
9
10
11
# File 'lib/trocla/stores/moneta.rb', line 4

def initialize(config,trocla)
  super(config,trocla)
  require 'moneta'
  # load expire support by default
  adapter_options = { :expires => true }.merge(
                        store_config['adapter_options']||{})
  @moneta = Moneta.new(store_config['adapter'],adapter_options)
end

Instance Attribute Details

#monetaObject (readonly)

Returns the value of attribute moneta.



3
4
5
# File 'lib/trocla/stores/moneta.rb', line 3

def moneta
  @moneta
end

Instance Method Details

#closeObject



13
14
15
# File 'lib/trocla/stores/moneta.rb', line 13

def close
  moneta.close
end

#get(key, format) ⇒ Object



17
18
19
# File 'lib/trocla/stores/moneta.rb', line 17

def get(key,format)
  moneta.fetch(key, {})[format]
end