Class: Trebuchet::Backend::Memcached

Inherits:
Object
  • Object
show all
Defined in:
lib/trebuchet/backend/memcached.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#namespaceObject

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, options = nil)
  @memcache.set(key(feature), get_strategy(feature) + [strategy, options])
end

#get_feature_namesObject



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, options = nil)
  @memcache.set(key(feature), [strategy, options])
end