Class: Trebuchet::Backend::Memcached
- Inherits:
-
Object
- Object
- Trebuchet::Backend::Memcached
- Defined in:
- lib/trebuchet/backend/memcached.rb
Instance Attribute Summary collapse
-
#namespace ⇒ Object
Returns the value of attribute namespace.
Instance Method Summary collapse
- #append_strategy(feature, strategy, options = nil) ⇒ Object
- #get_feature_names ⇒ Object
- #get_strategy(feature_name) ⇒ Object
-
#initialize(*args) ⇒ Memcached
constructor
A new instance of Memcached.
- #set_strategy(feature, strategy, options = nil) ⇒ Object
Constructor Details
#initialize(*args) ⇒ Memcached
Returns a new instance of Memcached.
7 8 9 10 |
# File 'lib/trebuchet/backend/memcached.rb', line 7 def initialize(*args) @memcache = MemCache.new(*args) @namespace = 'trebuchet/' end |
Instance Attribute Details
#namespace ⇒ Object
Returns the value of attribute namespace.
5 6 7 |
# File 'lib/trebuchet/backend/memcached.rb', line 5 def namespace @namespace end |
Instance Method Details
#append_strategy(feature, strategy, options = nil) ⇒ Object
20 21 22 |
# File 'lib/trebuchet/backend/memcached.rb', line 20 def append_strategy(feature, strategy, = nil) @memcache.set(key(feature), get_strategy(feature) + [strategy, ]) end |
#get_feature_names ⇒ Object
24 25 26 |
# File 'lib/trebuchet/backend/memcached.rb', line 24 def get_feature_names [] # TODO: store all key names end |
#get_strategy(feature_name) ⇒ Object
12 13 14 |
# File 'lib/trebuchet/backend/memcached.rb', line 12 def get_strategy(feature_name) @memcache.get(key(feature_name)) end |
#set_strategy(feature, strategy, options = nil) ⇒ Object
16 17 18 |
# File 'lib/trebuchet/backend/memcached.rb', line 16 def set_strategy(feature, strategy, = nil) @memcache.set(key(feature), [strategy, ]) end |