Class: Spymemcached::Rails23

Inherits:
Object
  • Object
show all
Defined in:
lib/spymemcached/rails23.rb

Defined Under Namespace

Modules: Response

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Rails23

Returns a new instance of Rails23.



13
14
15
# File 'lib/spymemcached/rails23.rb', line 13

def initialize(client)
  @client = client
end

Instance Method Details

#add(key, value, ttl = 0, raw = false) ⇒ Object



28
29
30
# File 'lib/spymemcached/rails23.rb', line 28

def add(key, value, ttl=0, raw=false)
  op(:add, key, value, ttl, opts(raw)) ? Response::STORED : Response::NOT_STORED
end

#decr(key, by = 1, ttl = 0) ⇒ Object



44
45
46
# File 'lib/spymemcached/rails23.rb', line 44

def decr(key, by=1, ttl=0)
  op(:decr, key, by, ttl)
end

#delete(key, *args) ⇒ Object



36
37
38
# File 'lib/spymemcached/rails23.rb', line 36

def delete(key, *args)
  op(:delete, key) ? Response::DELETED : Response::NOT_FOUND
end

#flush_allObject



48
49
50
# File 'lib/spymemcached/rails23.rb', line 48

def flush_all
  op(:flush_all)
end

#get(key, *args) ⇒ Object



24
25
26
# File 'lib/spymemcached/rails23.rb', line 24

def get(key, *args)
  op(:get, key)
end

#get_multi(*args) ⇒ Object



17
18
19
20
21
22
# File 'lib/spymemcached/rails23.rb', line 17

def get_multi(*args)
  if [Hash, TrueClass, FalseClass].include?(args.last)
    args.pop
  end
  op(:get_multi, *args)
end

#incr(key, by = 1, ttl = 0) ⇒ Object



40
41
42
# File 'lib/spymemcached/rails23.rb', line 40

def incr(key, by=1, ttl=0)
  op(:incr, key, by, ttl)
end

#set(key, value, ttl = 0, raw = false) ⇒ Object



32
33
34
# File 'lib/spymemcached/rails23.rb', line 32

def set(key, value, ttl=0, raw=false)
  op(:set, key, value, ttl, opts(raw)) ? Response::STORED : Response::NOT_STORED
end

#shutdownObject



56
57
58
# File 'lib/spymemcached/rails23.rb', line 56

def shutdown
  op(:shutdown)
end

#statsObject



52
53
54
# File 'lib/spymemcached/rails23.rb', line 52

def stats
  op(:stats)
end