Class: GAE::Memcache

Inherits:
Object
  • Object
show all
Defined in:
lib/rb-gae-support/memcache.rb

Overview

Wraps the google app engine memcache service. Can be used like a big hash

Class Method Summary collapse

Class Method Details

.[](key) ⇒ Object

Retrieves an object from the Memcache store by it’s key



8
9
10
# File 'lib/rb-gae-support/memcache.rb', line 8

def self.[](key)
  get_svc.get(key)
end

.[]=(key, value) ⇒ Object

Sets an object into memcache.



13
14
15
# File 'lib/rb-gae-support/memcache.rb', line 13

def self.[]=(key,value)
  put(key, value)
end

.delete(key) ⇒ Object

Deletes the object from the store



28
29
30
# File 'lib/rb-gae-support/memcache.rb', line 28

def self.delete(key)
  get_svc.delete(key)
end

.put(key, value, expire_millis = nil) ⇒ Object

Adds an object to the store, otionally setting it’s expiry X milliseconds in the future.



18
19
20
21
22
23
24
25
# File 'lib/rb-gae-support/memcache.rb', line 18

def self.put(key, value, expire_millis=nil)
  if expire_millis
    exp = com.google.appengine.api.memcache.Expiration.byDeltaMillis(expire_millis)
    get_svc.put(key, value, exp)
  else
    get_svc.put(key, value)
  end
end