Class: URI::Meta::Cache

Inherits:
Object
  • Object
show all
Defined in:
lib/uri/meta.rb

Constant Summary collapse

@@cache =
Moneta::Memory.new
@@expires_in =

24 hours

86_400

Class Method Summary collapse

Class Method Details

.cache=(cache) ⇒ Object



139
140
141
142
# File 'lib/uri/meta.rb', line 139

def cache=(cache)
  warn 'Turning off caching is poor form, for longer processes consider using moneta/memcached' if cache.nil?
  @@cache = cache
end

.expires_in=(seconds) ⇒ Object



144
145
146
# File 'lib/uri/meta.rb', line 144

def expires_in=(seconds)
  @@expires_in = seconds
end

.get(id) ⇒ Object



135
136
137
# File 'lib/uri/meta.rb', line 135

def get(id)
  @@cache[id] unless @@cache.nil?
end

.store(uid, obj) ⇒ Object



131
132
133
# File 'lib/uri/meta.rb', line 131

def store(uid, obj)
  @@cache.store(uid, obj, :expires_in => @@expires_in) unless @@cache.nil?
end