Module: MongoStore::Cache::Rails3

Included in:
MartSearch::MongoCache
Defined in:
lib/martsearch.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) read_entry(key, options = {})

Monkey patch :( - it looks like sometimes we don't get the full object back from the database so i'm just experimenting with the timeout flag to see if that's causing the issues (as our cached objects can be fairly big).



43
44
45
46
47
# File 'lib/martsearch.rb', line 43

def read_entry(key, options={})
  opts = { 'expires' => {'$gt' => Time.now}, 'timeout' => false }.merge!(options)
  doc  = collection.find_one( opts.merge({ '_id' => key }) )
  ActiveSupport::Cache::Entry.new(doc['value']) if doc
end