MemCachedAbstract

Abstract class for MemCached. Use the "arta\Cache" object factory to create instances of this class.
Source
MemCachedAbstract.php
Implements
ICacheAbstract
Depends on
Memcached
Since
1.2.2

Methods

__construct

MemCachedAbstract $obj = new MemCachedAbstract(server=localhost string|array, port=11211 int)

Constructor - creates/connects memcache object/server.

Arguments

    string|array (server=localhost)
    Host|array of servers
    int (port=11211)
    Port (if host is not array)

Returns

void

__get

mixed __get(string key)

Get cached data.

Arguments

    key (string)
    Cache key

Returns

mixed
Cached value

__isset

bool __isset(string key)

Check if cache key exists.

Arguments

    key (string)
    Cache key

Returns

bool
true=key exists in cache

__set

void __set(string key, mixed value)

Store data in cache.

Arguments

    key (string)
    Cache key
    value (mixed)
    Data to cache

Returns

void

__unset

void __unset(string key)

Delete data from cache.

Arguments

    key (string)
    Cache key

Returns

void

add

bool $obj->add(string key, mixed value, int | string expire=0)

Store data in cache only if key not already exists in cache.

Arguments

    key (string)
    Cache key
    value (mixed)
    Data to cache
    expire=0 (int | string)
    Expire time in seconds. 'I'=minute, 'H'=hour, 'D'=day and 'M'=month can be added to the time(number) to define the unit. e.g: "12M"

Returns

bool
State of success

clear

bool $obj->clear()

Clear all caches.

Returns

bool
State of success

close

void $obj->close()

Close memcache server connnnection.

Returns

void

dec

int $obj->dec(string key, int step=1)

Decrease cache value.

Arguments

    key (string)
    Cache key
    step=1 (int)
    Decrement

Returns

int
Current value

delete

bool $obj->delete(string key)

Delete data from cache.

Arguments

    key (string)
    Cache key

Returns

bool
State of success

get

mixed $obj->get(string key, bool &success=null)

Fetch a cached value.

Arguments

    key (string)
    Cache key
    &success=null (bool)
    false=could not read value or key not exists(byref)

Returns

mixed
Cached data

has

bool $obj->has(string key)

Check if cache key exists.

Arguments

    key (string)
    Cache key

Returns

bool
true=key exists in cache

hasValue

bool $obj->hasValue(string key, mixed val)

Check if a key has a given value CACHE[key] === val.

Arguments

    key (string)
    Key to compare it's value
    val (mixed)
    Value to be compared to

Returns

bool
true=key has the given value

inc

int $obj->inc(string key, int step=1)

Increment cache value.

Arguments

    key (string)
    Cache key
    step=1 (int)
    Increment

Returns

int
Current value

server

void $obj->server(server=localhost string|array, port=11211 int)

Add server connections.

Arguments

    string|array (server=localhost)
    Host|array of servers
    int (port=11211)
    Port (if host is not array)

Returns

void

set

bool $obj->set(string key, mixed value, int | string expire=0)

Store data in cache.

Arguments

    key (string)
    Cache key
    value (mixed)
    Data to cache
    expire=0 (int | string)
    Expire time in seconds. 'I'=minute, 'H'=hour, 'D'=day and 'M'=month can be added to the time(number) to define the unit. e.g: "12M"

Returns

bool
State of success