Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members | Related Pages

memcached Class Reference

List of all members.

Public Member Functions

 memcached ($args)
 add ($key, $val, $exp=0)
 decr ($key, $amt=1)
 delete ($key, $time=0)
 disconnect_all ()
 enable_compress ($enable)
 forget_dead_hosts ()
 get ($key)
 get_multi ($keys)
 incr ($key, $amt=1)
 replace ($key, $value, $exp=0)
 run_command ($sock, $cmd)
 set ($key, $value, $exp=0)
 set_compress_threshold ($thresh)
 set_debug ($dbg)
 set_servers ($list)
 _close_sock ($sock)
 _connect_sock (&$sock, $host, $timeout=0.25)
 _dead_sock ($sock)
 get_sock ($key)
 _hashfunc ($key)
 _incrdecr ($cmd, $key, $amt=1)
 _load_items ($sock, &$ret)
 _set ($cmd, $key, $val, $exp)
 sock_to_host ($host)
 _debugprint ($str)

Public Attributes

 $stats
 $_cache_sock
 $_debug
 $_host_dead
 $_have_zlib
 $_compress_enable
 $_compress_threshold
 $_persistant
 $_single_sock
 $_servers
 $_buckets
 $_bucketcount
 $_active

Constructor & Destructor Documentation

memcached::memcached args  ) 
 

Memcache initializer

Parameters:
array $args Associative array of settings
Returns:
mixed public

Definition at line 222 of file memcached-client.php.

References $args, and set_servers().


Member Function Documentation

memcached::_close_sock sock  ) 
 

Close the specified socket

Parameters:
string $sock Socket to close
private

Definition at line 621 of file memcached-client.php.

References _close_sock().

Referenced by _close_sock().

memcached::_connect_sock &$  sock,
host,
timeout = 0.25
 

Connects $sock to $host, timing out after $timeout

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

Definition at line 641 of file memcached-client.php.

References $sock, and _connect_sock().

Referenced by _connect_sock().

memcached::_dead_sock sock  ) 
 

Marks a host as dead until 30-40 seconds in the future

Parameters:
string $sock Socket to mark as dead
private

Definition at line 667 of file memcached-client.php.

References _dead_sock().

Referenced by _dead_sock(), delete(), get(), and get_multi().

memcached::_debugprint str  ) 
 

Definition at line 941 of file memcached-client.php.

References _debugprint().

Referenced by _debugprint(), _load_items(), _set(), delete(), get(), and get_multi().

memcached::_hashfunc key  ) 
 

Creates a hash interger based on the $key

Parameters:
string $key Key to hash
Returns:
interger Hash value private

Definition at line 738 of file memcached-client.php.

References _hashfunc().

Referenced by _hashfunc(), and get_sock().

memcached::_incrdecr cmd,
key,
amt = 1
 

Perform increment/decriment on $key

Parameters:
string $cmd Command to perform
string $key Key to perform it on
interger $amt Amount to adjust
Returns:
interger New value of $key private

Definition at line 756 of file memcached-client.php.

References $line, $sock, and _incrdecr().

Referenced by _incrdecr(), decr(), and incr().

memcached::_load_items sock,
&$  ret
 

Load items into $ret from $sock

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

Definition at line 788 of file memcached-client.php.

References $n, _debugprint(), _load_items(), data, MEMCACHE_COMPRESSED, MEMCACHE_SERIALIZED, and n.

Referenced by _load_items(), get(), and get_multi().

memcached::_set cmd,
key,
val,
exp
 

Performs the requested storage operation to the memcache server

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

Definition at line 854 of file memcached-client.php.

References $line, $sock, _debugprint(), _set(), data, MEMCACHE_COMPRESSED, and MEMCACHE_SERIALIZED.

Referenced by _set(), add(), replace(), and set().

memcached::add key,
val,
exp = 0
 

Adds a key/value to the memcache server if one isn't already set with that key

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

Definition at line 250 of file memcached-client.php.

References _set(), and add().

Referenced by add().

memcached::decr key,
amt = 1
 

Decriment a value stored on the memcache server

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

Definition at line 267 of file memcached-client.php.

References _incrdecr(), and decr().

Referenced by decr().

memcached::delete key,
time = 0
 

Deletes a key from the server, optionally after $time

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

Definition at line 284 of file memcached-client.php.

References $res, $sock, _dead_sock(), _debugprint(), and get_sock().

memcached::disconnect_all  ) 
 

Disconnects all connected sockets

public

Definition at line 320 of file memcached-client.php.

memcached::enable_compress enable  ) 
 

Enable / Disable compression

Parameters:
boolean $enable TRUE to enable, FALSE to disable
public

Definition at line 338 of file memcached-client.php.

References enable_compress().

Referenced by enable_compress().

memcached::forget_dead_hosts  ) 
 

Forget about all of the dead hosts

public

Definition at line 351 of file memcached-client.php.

memcached::get key  ) 
 

Retrieves the value associated with the key from the memcache server

Parameters:
string $key Key to retrieve
Returns:
mixed public

Definition at line 367 of file memcached-client.php.

References $sock, _dead_sock(), _debugprint(), _load_items(), get(), and get_sock().

Referenced by get().

memcached::get_multi keys  ) 
 

Get multiple keys from the server(s)

Parameters:
array $keys Keys to retrieve
Returns:
array public

Definition at line 407 of file memcached-client.php.

References $sock, _dead_sock(), _debugprint(), _load_items(), get_multi(), and get_sock().

Referenced by get_multi().

memcached::get_sock key  ) 
 

get_sock

Parameters:
string $key Key to retrieve value for;
Returns:
mixed resource on success, false on failure private

Definition at line 687 of file memcached-client.php.

References $i, $sock, _hashfunc(), get_sock(), and sock_to_host().

Referenced by delete(), get(), get_multi(), and get_sock().

memcached::incr key,
amt = 1
 

Increments $key (optionally) by $amt

Parameters:
string $key Key to increment
interger $amt (optional) amount to increment
Returns:
interger New key value? public

Definition at line 472 of file memcached-client.php.

References _incrdecr(), and incr().

Referenced by incr().

memcached::replace key,
value,
exp = 0
 

Overwrites an existing value for key; only works if key is already set

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

Definition at line 490 of file memcached-client.php.

References _set(), and replace().

Referenced by replace().

memcached::run_command sock,
cmd
 

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
. More specifically, my testing has shown that, on FreeBSD at least, each line is terminated only with a
. This is with the PHP flag auto_detect_line_endings set to falase (the default).

Parameters:
resource $sock Socket to send command on
string $cmd Command to run
Returns:
array Output array public

Definition at line 514 of file memcached-client.php.

References $res, and run_command().

Referenced by run_command().

memcached::set key,
value,
exp = 0
 

Unconditionally sets a key to a given value in the memcache. Returns true if set successfully.

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

Definition at line 548 of file memcached-client.php.

References _set(), and set().

Referenced by set().

memcached::set_compress_threshold thresh  ) 
 

Sets the compression threshold

Parameters:
interger $thresh Threshold to compress if larger than
public

Definition at line 563 of file memcached-client.php.

References set_compress_threshold().

Referenced by set_compress_threshold().

memcached::set_debug dbg  ) 
 

Sets the debug flag

Parameters:
boolean $dbg TRUE for debugging, FALSE otherwise
public

See also:
memcahced::memcached

Definition at line 580 of file memcached-client.php.

References set_debug().

Referenced by set_debug().

memcached::set_servers list  ) 
 

Sets the server list to distribute key gets and puts between

Parameters:
array $list Array of servers to connect to
public

See also:
memcached::memcached()

Definition at line 597 of file memcached-client.php.

References $list, and set_servers().

Referenced by memcached(), and set_servers().

memcached::sock_to_host host  ) 
 

Returns the socket for the host

Parameters:
string $host Host:IP to get socket for
Returns:
mixed IO Stream or false private

Definition at line 919 of file memcached-client.php.

References $sock, and sock_to_host().

Referenced by get_sock(), and sock_to_host().


Member Data Documentation

memcached::$_active
 

Definition at line 206 of file memcached-client.php.

memcached::$_bucketcount
 

Definition at line 198 of file memcached-client.php.

memcached::$_buckets
 

Definition at line 190 of file memcached-client.php.

memcached::$_cache_sock
 

Definition at line 118 of file memcached-client.php.

memcached::$_compress_enable
 

Definition at line 150 of file memcached-client.php.

memcached::$_compress_threshold
 

Definition at line 158 of file memcached-client.php.

memcached::$_debug
 

Definition at line 126 of file memcached-client.php.

memcached::$_have_zlib
 

Definition at line 142 of file memcached-client.php.

memcached::$_host_dead
 

Definition at line 134 of file memcached-client.php.

memcached::$_persistant
 

Definition at line 166 of file memcached-client.php.

memcached::$_servers
 

Definition at line 182 of file memcached-client.php.

memcached::$_single_sock
 

Definition at line 174 of file memcached-client.php.

memcached::$stats
 

Definition at line 107 of file memcached-client.php.


The documentation for this class was generated from the following file:
Generated on Tue Jun 29 23:40:50 2004 for Mediawiki by doxygen 1.3.7