[ Index ]
 

Code source de LifeType 1.2.4

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/class/cache/Memcached_Client/ -> memcached-client.php (sommaire)

This is the PHP client for memcached - a distributed memory cache daemon. More information is available at http://www.danga.com/memcached/ Usage example:

Author: Ryan T. Dean <rtdean@cytherianage.net>
Version: 0.1.2
Poids: 1078 lignes (28 kb)
Inclus ou requis:0 fois
Référencé: 1 fois
Nécessite: 0 fichiers

Définit 1 class

memcached:: (30 méthodes):
  memcached()
  add()
  decr()
  delete()
  flush_all()
  disconnect_all()
  enable_compress()
  forget_dead_hosts()
  get()
  get_multi()
  incr()
  replace()
  run_command()
  set()
  set_compress_threshold()
  set_debug()
  set_servers()
  set_timeout()
  _close_sock()
  _connect_sock()
  _dead_sock()
  get_sock()
  _hashfunc()
  _incrdecr()
  _load_items()
  _set()
  sock_to_host()
  _debugprint()
  _safe_fwrite()
  _flush_read_buffer()


Classe: memcached  - X-Ref

memcached client class implemented using (p)fsockopen()

memcached($args)   X-Ref
Memcache initializer

param: array    $args    Associative array of settings
return: mixed

add($key, $val, $exp = 0)   X-Ref
Adds a key/value to the memcache server if one isn't already set with
that key

param: string   $key     Key to set with data
param: mixed    $val     Value to store
param: interger $exp     (optional) Time to expire data at
return: boolean

decr($key, $amt=1)   X-Ref
Decriment a value stored on the memcache server

param: string   $key     Key to decriment
param: interger $amt     (optional) Amount to decriment
return: mixed    FALSE on failure, value on success

delete($key, $time = 0)   X-Ref
Deletes a key from the server, optionally after $time

param: string   $key     Key to delete
param: interger $time    (optional) How long to wait before deleting
return: boolean  TRUE on success, FALSE on failure

flush_all()   X-Ref
Flush all keys from the server

return: boolean  Always TRUE

disconnect_all()   X-Ref
Disconnects all connected sockets


enable_compress($enable)   X-Ref
Enable / Disable compression

param: boolean  $enable  TRUE to enable, FALSE to disable

forget_dead_hosts()   X-Ref
Forget about all of the dead hosts


get($key)   X-Ref
Retrieves the value associated with the key from the memcache server

param: string   $key     Key to retrieve
return: mixed

get_multi($keys)   X-Ref
Get multiple keys from the server(s)

param: array    $keys    Keys to retrieve
return: array

incr($key, $amt=1)   X-Ref
Increments $key (optionally) by $amt

param: string   $key     Key to increment
param: interger $amt     (optional) amount to increment
return: interger New key value?

replace($key, $value, $exp=0)   X-Ref
Overwrites an existing value for key; only works if key is already set

param: string   $key     Key to set value as
param: mixed    $value   Value to store
param: interger $exp     (optional) Experiation time
return: boolean

run_command($sock, $cmd)   X-Ref
Passes through $cmd to the memcache server connected by $sock; returns
output as an array (null array if no output)

NOTE: due to a possible bug in how PHP reads while using fgets(), each
line may not be terminated by a \r\n.  More specifically, my testing
has shown that, on FreeBSD at least, each line is terminated only
with a \n.  This is with the PHP flag auto_detect_line_endings set
to falase (the default).

param: resource $sock    Socket to send command on
param: string   $cmd     Command to run
return: array    Output array

set($key, $value, $exp=0)   X-Ref
Unconditionally sets a key to a given value in the memcache.  Returns true
if set successfully.

param: string   $key     Key to set value as
param: mixed    $value   Value to set
param: interger $exp     (optional) Experiation time
return: boolean  TRUE on success

set_compress_threshold($thresh)   X-Ref
Sets the compression threshold

param: interger $thresh  Threshold to compress if larger than

set_debug($dbg)   X-Ref
Sets the debug flag

param: boolean  $dbg     TRUE for debugging, FALSE otherwise

set_servers($list)   X-Ref
Sets the server list to distribute key gets and puts between

param: array    $list    Array of servers to connect to

set_timeout($seconds, $microseconds)   X-Ref
Sets the timeout for new connections

param: integer  $seconds Number of seconds
param: integer  $microseconds  Number of microseconds

_close_sock($sock)   X-Ref
Close the specified socket

param: string   $sock    Socket to close

_connect_sock(&$sock, $host, $timeout = 0.25)   X-Ref
Connects $sock to $host, timing out after $timeout

param: interger $sock    Socket to connect
param: string   $host    Host:IP to connect to
param: float    $timeout (optional) Timeout value, defaults to 0.25s
return: boolean

_dead_sock($sock)   X-Ref
Marks a host as dead until 30-40 seconds in the future

param: string   $sock    Socket to mark as dead

get_sock($key)   X-Ref
get_sock

param: string   $key     Key to retrieve value for;
return: mixed    resource on success, false on failure

_hashfunc($key)   X-Ref
Creates a hash interger based on the $key

param: string   $key     Key to hash
return: interger Hash value

_incrdecr($cmd, $key, $amt=1)   X-Ref
Perform increment/decriment on $key

param: string   $cmd     Command to perform
param: string   $key     Key to perform it on
param: interger $amt     Amount to adjust
return: interger    New value of $key

_load_items($sock, &$ret)   X-Ref
Load items into $ret from $sock

param: resource $sock    Socket to read from
param: array    $ret     Returned values

_set($cmd, $key, $val, $exp)   X-Ref
Performs the requested storage operation to the memcache server

param: string   $cmd     Command to perform
param: string   $key     Key to act on
param: mixed    $val     What we need to store
param: interger $exp     When it should expire
return: boolean

sock_to_host($host)   X-Ref
Returns the socket for the host

param: string   $host    Host:IP to get socket for
return: mixed    IO Stream or false

_debugprint($str)   X-Ref
Pas de description

_safe_fwrite($f, $buf, $len = false)   X-Ref
Write to a stream, timing out after the correct amount of time

return: bool false on failure, true on success

_flush_read_buffer($f)   X-Ref
Flush the read buffer of a stream




Généré le : Mon Nov 26 21:04:15 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics