Class: MasterForest::MemcacheTerm
- Defined in:
- lib/master_forest/memcache_term.rb
Instance Method Summary collapse
- #fully_reduce(depth = Float::INFINITY) ⇒ Object
-
#initialize(raw, left = nil, right = nil) ⇒ MemcacheTerm
constructor
A new instance of MemcacheTerm.
Methods inherited from Term
#==, #l, #leaf?, #normal?, #r, #reduce, #to_s, #valid?
Constructor Details
#initialize(raw, left = nil, right = nil) ⇒ MemcacheTerm
Returns a new instance of MemcacheTerm.
5 6 7 8 |
# File 'lib/master_forest/memcache_term.rb', line 5 def initialize raw, left = nil, right = nil @cache = Dalli::Client.new 'localhost:11211' super raw, left, right end |
Instance Method Details
#fully_reduce(depth = Float::INFINITY) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/master_forest/memcache_term.rb', line 10 def fully_reduce depth = Float::INFINITY cur = self redices = [self] 1.upto(depth) do reduced = @cache.get cur.to_s if reduced cache! redices, reduced return reduced end reduced = cur.reduce if reduced.normal? cache! redices, reduced return reduced else redices << reduced end cur = reduced end cur end |