class Memcached::Client

Defined in:

memcached/client.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(host = "localhost", port = 11211) #

Opens connection to memcached server

Options

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

[View source]

Instance Method Detail

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

Append value afrer an existing key value


[View source]
def 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.


[View source]
def delete(key : String) : Bool #

Deletes the key from memcached.


[View source]
def 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.


[View source]
def flush(delay = 0_u32) : Bool #

Remove all keys from memcached.

Passing delay parameter postpone the removal.


[View source]
def get(key : String) : String | Nil #

Get single key value from memcached.


[View source]
def 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


[View source]
def get_with_version(key : String) : Tuple(String, Int64) | Nil #

Get single key value and its current version.


[View source]
def 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.


[View source]
def prepend(key : String, value : String) : Bool #

Prepend value before an existing key value


[View source]
def 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.


[View source]
def touch(key : String, expire : Number) : Bool #

Update key expiration time


[View source]