class

Memcached::Client

Inherits Reference < Object

Constructors

new(host = "localhost", port = 11211)

Opens connection to memcached server

Options

  • host : String - memcached host
  • port : Number - memcached port
Source

Instance methods

append(key : String, value : String) : Bool

Append value afrer an existing key value

Source
decrement(key : String, delta : Number, initial_value : Number = 0, expire : Number = 0) : Int64 | Nil

Decrement key value by delta.

If key does not exist, it will be set to initial_value.

Source
delete(key : String) : Bool

Deletes the key from memcached.

Source
fetch(key : String, expire : Number = 0, version : Number = 0, &) : String | Nil

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.

Source
flush(delay = 0_u32) : Bool

Remove all keys from memcached.

Passing delay parameter postpone the removal.

Source
get(key : String) : String | Nil

Get single key value from memcached.

Source
get_multi(keys : Array(String)) : Hash(String, String | Nil)

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

Source
get_with_version(key : String) : Tuple(String, Int64) | Nil

Get single key value and its current version.

Source
increment(key : String, delta : Number, initial_value = 0, expire = 0) : Int64 | Nil

Increment key value by delta.

If key does not exist, it will be set to initial_value.

Source
prepend(key : String, value : String) : Bool

Prepend value before an existing key value

Source
set(key : String, value : String, expire : Number = 0, version : Number = 0) : Int64

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.

Source
touch(key : String, expire : Number) : Bool

Update key expiration time

Source