Class: MemcachePod::Client
- Inherits:
-
Object
- Object
- MemcachePod::Client
- Defined in:
- lib/memcachepod/client.rb
Instance Method Summary collapse
- #add(key, value, ttl = nil, options = nil) ⇒ Object
- #alive! ⇒ Object
- #append(key, value) ⇒ Object
- #decr(key, amt = 1, ttl = nil, default = nil) ⇒ Object
- #delete(key) ⇒ Object
- #flush(delay = 0) ⇒ Object (also: #flush_all)
- #get(key, options = nil) ⇒ Object
- #get_memory_usage ⇒ Object
- #get_options ⇒ Object
- #get_status ⇒ Object
- #incr(key, amt = 1, ttl = nil, default = nil) ⇒ Object
-
#initialize(servers = nil, options = {}) ⇒ Client
constructor
MemcachePod::Client is the main class which developers will use to interact with.
- #prepend(key, value) ⇒ Object
- #replace(key, value, ttl = nil, options = nil) ⇒ Object
- #reset_stats ⇒ Object
- #set(key, value, ttl = nil, options = nil) ⇒ Object
- #stats(type = nil) ⇒ Object
- #touch(key, ttl = nil) ⇒ Object
- #version ⇒ Object
Constructor Details
#initialize(servers = nil, options = {}) ⇒ Client
MemcachePod::Client is the main class which developers will use to interact with.
MemcachePod::Client.new([‘localhost:11211:10’, ‘cache-2:11211:5’]
,threadsafe => true, :expires_in => 300)
This class aims to keep compatiblity ather memcache client.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/memcachepod/client.rb', line 15 def initialize(servers=nil, ={}) = Hash.new [:expires_in] = 0 [:threadsafe] = true [:namespace] = '' [:max_memory] = 64*1024*1024 # same as memcached if .has_key?(:expires_in) [:expires_in] = [:expires_in] end if .has_key?(:threadsafe) [:threadsafe] = [:threadsafe] end if .has_key?(:namespace) [:namespace] = [:namespace] end if .has_key?(:max_memory) [:max_memory] = [:max_memory] end @memory = Memory.new([:max_memory]) end |
Instance Method Details
#add(key, value, ttl = nil, options = nil) ⇒ Object
50 51 52 |
# File 'lib/memcachepod/client.rb', line 50 def add(key, value, ttl=nil, =nil) raise NotImplementedError.new("not implemented add()") end |
#alive! ⇒ Object
90 91 92 |
# File 'lib/memcachepod/client.rb', line 90 def alive! raise NotImplementedError.new("not implemented alive!()") end |
#append(key, value) ⇒ Object
62 63 64 |
# File 'lib/memcachepod/client.rb', line 62 def append(key, value) raise NotImplementedError.new("not implemented append()") end |
#decr(key, amt = 1, ttl = nil, default = nil) ⇒ Object
74 75 76 |
# File 'lib/memcachepod/client.rb', line 74 def decr(key, amt=1, ttl=nil, default=nil) raise NotImplementedError.new("not implemented decr()") end |
#delete(key) ⇒ Object
58 59 60 |
# File 'lib/memcachepod/client.rb', line 58 def delete(key) @memory.delete(key) end |
#flush(delay = 0) ⇒ Object Also known as: flush_all
98 99 100 |
# File 'lib/memcachepod/client.rb', line 98 def flush(delay=0) @memory.flush() end |
#get(key, options = nil) ⇒ Object
39 40 41 42 |
# File 'lib/memcachepod/client.rb', line 39 def get(key, =nil) key = validate_key(key) return @memory.get(key, ) end |
#get_memory_usage ⇒ Object
112 113 114 |
# File 'lib/memcachepod/client.rb', line 112 def get_memory_usage return @memory.get_memory_usage end |
#get_options ⇒ Object
108 109 110 |
# File 'lib/memcachepod/client.rb', line 108 def return end |
#get_status ⇒ Object
102 103 104 |
# File 'lib/memcachepod/client.rb', line 102 def get_status return @memory.get_status end |
#incr(key, amt = 1, ttl = nil, default = nil) ⇒ Object
70 71 72 |
# File 'lib/memcachepod/client.rb', line 70 def incr(key, amt=1, ttl=nil, default=nil) raise NotImplementedError.new("not implemented incr()") end |
#prepend(key, value) ⇒ Object
66 67 68 |
# File 'lib/memcachepod/client.rb', line 66 def prepend(key, value) raise NotImplementedError.new("not implemented prepend()") end |
#replace(key, value, ttl = nil, options = nil) ⇒ Object
54 55 56 |
# File 'lib/memcachepod/client.rb', line 54 def replace(key, value, ttl=nil, =nil) raise NotImplementedError.new("not implemented replace()") end |
#reset_stats ⇒ Object
86 87 88 |
# File 'lib/memcachepod/client.rb', line 86 def reset_stats raise NotImplementedError.new("not implemented reset_stats()") end |
#set(key, value, ttl = nil, options = nil) ⇒ Object
44 45 46 47 48 |
# File 'lib/memcachepod/client.rb', line 44 def set(key, value, ttl=nil, =nil) key = validate_key(key) ttl = ttl_or_default(ttl) @memory.set(key, value, ttl, ) end |
#stats(type = nil) ⇒ Object
82 83 84 |
# File 'lib/memcachepod/client.rb', line 82 def stats(type=nil) raise NotImplementedError.new("not implemented stats()") end |
#touch(key, ttl = nil) ⇒ Object
78 79 80 |
# File 'lib/memcachepod/client.rb', line 78 def touch(key, ttl=nil) raise NotImplementedError.new("not implemented touch()") end |
#version ⇒ Object
94 95 96 |
# File 'lib/memcachepod/client.rb', line 94 def version { "localhost" => MemcachePod::VERSION } end |