MemCacheAbstract

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

Methods

__construct

MemCacheAbstract $obj = new MemCacheAbstract(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

addServer

void $obj->addServer(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

clear

bool $obj->clear()

Clear all caches.

Returns

bool
State of success

close

void $obj->close()

Close memcache server connection.

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

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

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