Object
# File lib/moneta/mongodb.rb, line 12 def initialize(options = {}) options = { :host => ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost', :port => ENV['MONGO_RUBY_DRIVER_PORT'] || XGen::Mongo::Driver::Mongo::DEFAULT_PORT, :db => 'cache', :collection => 'cache' }.update(options) conn = XGen::Mongo::Driver::Mongo.new(options[:host], options[:port]) @cache = conn.db(options[:db]).collection(options[:collection]) end
# File lib/moneta/mongodb.rb, line 27 def [](key) res = @cache.find_first('_id' => key) res = nil if res && res['expires'] && Time.now > res['expires'] res && res['data'] end
# File lib/moneta/mongodb.rb, line 33 def []=(key, value) store(key, value) end
# File lib/moneta/mongodb.rb, line 37 def delete(key) value = self[key] @cache.remove('_id' => key) if value value end
# File lib/moneta/mongodb.rb, line 23 def key?(key) !!self[key] end
Generated with the Darkfish Rdoc Generator 2.