Module: Cache

Defined in:
lib/cache.rb,
lib/cache/config.rb,
lib/cache/storage.rb,
lib/cache/version.rb

Defined Under Namespace

Classes: Config, Storage

Constant Summary collapse

VERSION =
"0.0.1"

Class Method Summary collapse

Class Method Details

.configObject

:nodoc:



6
7
8
# File 'lib/cache.rb', line 6

def self.config #:nodoc:
  Config.instance
end

.delete(k) ⇒ Object

Delete a value.

Example:

Cache.delete 'hello'


31
32
33
# File 'lib/cache.rb', line 31

def self.delete(k)
  Storage.instance.delete k
end

.flushObject

Flush the cache.

Example:

Cache.flush


39
40
41
# File 'lib/cache.rb', line 39

def self.flush
  Storage.instance.flush
end

.get(k) ⇒ Object

Get a value.

Example:

Cache.get 'hello'


14
15
16
# File 'lib/cache.rb', line 14

def self.get(k)
  Storage.instance.get k
end

.set(k, v, ttl = nil) ⇒ Object

Store a value. Note that this will Marshal it.

Example:

Cache.set 'hello', 'world'
Cache.set 'hello', 'world', 80 # seconds til it expires


23
24
25
# File 'lib/cache.rb', line 23

def self.set(k, v, ttl = nil)
  Storage.instance.set k, v, ttl
end