class Memcached::Client
- Memcached::Client
- Reference
- Object
Defined in:
memcached/client.crConstructors
-
.new(host = "localhost", port = 11211)
Opens connection to memcached server
Instance Method Summary
-
#append(key : String, value : String) : Bool
Append value afrer an existing key value
-
#decrement(key : String, delta : Number, initial_value : Number = 0, expire : Number = 0) : Int64 | Nil
Decrement key value by delta.
-
#delete(key : String) : Bool
Deletes the key from memcached.
-
#fetch(key : String, expire : Number = 0, version : Number = 0, &) : String | Nil
Fetch the value associated with the key.
-
#flush(delay = 0_u32) : Bool
Remove all keys from memcached.
-
#get(key : String) : String | Nil
Get single key value from memcached.
-
#get_multi(keys : Array(String)) : Hash(String, String | Nil)
Get multiple keys values from memcached.
-
#get_with_version(key : String) : Tuple(String, Int64) | Nil
Get single key value and its current version.
-
#increment(key : String, delta : Number, initial_value = 0, expire = 0) : Int64 | Nil
Increment key value by delta.
-
#prepend(key : String, value : String) : Bool
Prepend value before an existing key value
-
#set(key : String, value : String, expire : Number = 0, version : Number = 0) : Int64
Set key - value pair in memcached.
-
#touch(key : String, expire : Number) : Bool
Update key expiration time
Constructor Detail
Opens connection to memcached server
Options
- host : String - memcached host
- port : Number - memcached port
Instance Method Detail
Decrement key value by delta.
If key does not exist, it will be set to initial_value.
Fetch the value associated with the key. If a value is found, then it is returned. If a value is not found, the block will be invoked and its return value (given that it is not nil) will be written to the cache.
Remove all keys from memcached.
Passing delay parameter postpone the removal.
Get multiple keys values from memcached.
If a key was not found or an error occured while getting the key, value for this key will be nil in the returned hash
Get single key value and its current version.
Increment key value by delta.
If key does not exist, it will be set to initial_value.
Set key - value pair in memcached.
By default the key is set without expiration time. If you want to set TTL for the key, pass TTL in seconds as expire parameter If version parameter is provided, it will be compared to existing key version in memcached. If versions differ, Memcached::BadVersionException will be raised.