.

GyroMemcache Class Reference
[Memcache]

Wrapper around memcache/memcached. More...

List of all members.

Static Public Member Functions

static  add ($key, $value, $lifetime_in_seconds)
  Set data on server.
static  add_server ($host= 'localhost', $port=11211)
  Add a server.
static  decrement ($key, $by=1)
  Decrement a counter.
static  delete ($key)
  Remove data.
static  get ($key)
  Returns data from server.
static  increment ($key, $by=1)
  Increment a counter.
static  init ()
  Init Memcache instance.
static  set ($key, $value, $lifetime_in_seconds)
  Set data on server.

Detailed Description

Wrapper around memcache/memcached.

Author:
Gerd Riesselmann

Definition at line 8 of file memcache.cls.php.


Member Function Documentation

static GyroMemcache::add ( key,
value,
lifetime_in_seconds  
) [static]

Set data on server.

Parameters:
string  $key
mixed  $value
int  $lifetime_in_seconds
Returns:
bool TRUE on success, FALSE otherwise

Definition at line 69 of file memcache.cls.php.

00069                                                                        {
00070                 if (self::$delegate instanceof Memcache) {
00071                         return self::$delegate->add($key, $value, false, $lifetime_in_seconds);
00072                 }
00073                 else {
00074                         return self::$delegate->add($key, $value, $lifetime_in_seconds);
00075                 }               
00076         }
static GyroMemcache::add_server ( host = 'localhost',
port = 11211  
) [static]

Add a server.

Parameters:
string  $host Server name or IP address
int  $port Port
int  $weight The weight of the server relative to the total weight of all the servers in the pool. This controls the probability of the server being selected for operations. This is used only with consistent distribution option and usually corresponds to the amount of memory available to memcache on that server.

Definition at line 42 of file memcache.cls.php.

00042                                                                               {
00043                 if (self::$delegate instanceof Memcache) {
00044                         self::$delegate->addServer($host, $port); // , true, $weight);
00045                 }
00046                 else {
00047                         self::$delegate->addServer($host, $port);
00048                 }
00049         }
static GyroMemcache::decrement ( key,
by = 1  
) [static]

Decrement a counter.

Parameters:
string  $key
int  $by
Returns:
int New Value or FALSE if $key does not exists

Definition at line 121 of file memcache.cls.php.

00121                                                         {
00122                 return self::$delegate->decrement($key, $by);
00123         }
static GyroMemcache::delete ( key  )  [static]

Remove data.

Parameters:
string  $key

Definition at line 99 of file memcache.cls.php.

00099                                             {
00100                 self::$delegate->delete($key);
00101         }
static GyroMemcache::get ( key  )  [static]

Returns data from server.

Parameters:
string  $key
Returns:
mixed

Definition at line 57 of file memcache.cls.php.

00057                                          {
00058                 return self::$delegate->get($key);      
00059         }
static GyroMemcache::increment ( key,
by = 1  
) [static]

Increment a counter.

Parameters:
string  $key
int  $by
Returns:
int New Value or FALSE if $key does not exists

Definition at line 110 of file memcache.cls.php.

00110                                                         {
00111                 return self::$delegate->increment($key, $by);
00112         }
static GyroMemcache::init (  )  [static]

Init Memcache instance.

Definition at line 19 of file memcache.cls.php.

00019                                       {
00020                 if (class_exists('Memcached')) {                
00021                         self::$delegate = new Memcached(Config::get_value(Config::TITLE));
00022                 }
00023                 else if (class_exists('Memcache')) {
00024                         self::$delegate = new Memcache();       
00025                 }
00026                 else {
00027                         throw new Exception('GyroMemcache::init(): No memcache extension installed');
00028                 }
00029         }
static GyroMemcache::set ( key,
value,
lifetime_in_seconds  
) [static]

Set data on server.

Parameters:
string  $key
mixed  $value
int  $lifetime_in_seconds

Definition at line 85 of file memcache.cls.php.

00085                                                                        {
00086                 if (self::$delegate instanceof Memcache) {
00087                         self::$delegate->set($key, $value, false, $lifetime_in_seconds);
00088                 }
00089                 else {
00090                         self::$delegate->set($key, $value, $lifetime_in_seconds);
00091                 }
00092         }

The documentation for this class was generated from the following file: