日期:2013-05-21 浏览次数:20538 次
MemCached的PHP客户端操作类二
<?php
/*
* MemCached PHP client
* Copyright (c) 2003
* Ryan Gilfether <hotrodder@rocketmail.com>
* http://www.gilfether.com
*
* Originally translated from Brad Fitzpatrick's <brad@danga.com> MemCached Perl client
* See the memcached website:
* http://www.danga.com/memcached/
*
* This module is Copyright (c) 2003 Ryan Gilfether.
* All rights reserved.
* You may distribute under the terms of the GNU General Public License
* This is free software. IT COMES WITHOUT WARRANTY OF ANY KIND.
*
*/
/**
* version string
*/
define("MC_VERSION", "1.0.10");
/**
* int, buffer size used for sending and receiving
* data from sockets
*/
define("MC_BUFFER_SZ", 1024);
/**
* MemCached error numbers
*/
define("MC_ERR_NOT_ACTIVE", 1001); // no active servers
define("MC_ERR_SOCKET_WRITE", 1002); // socket_write() failed
define("MC_ERR_SOCKET_READ", 1003); // socket_read() failed
define("MC_ERR_SOCKET_CONNECT", 1004); // failed to connect to host
define("MC_ERR_DELETE", 1005); // delete() did not recieve DELETED command
define("MC_ERR_HOST_FORMAT", 1006); // sock_to_host() invalid host format
define("MC_ERR_HOST_DEAD", 1007); // sock_to_host() host is dead
define("MC_ERR_GET_SOCK", 1008); // get_sock() failed to find a valid socket
define("MC_ERR_SET", 1009); // _set() failed to receive the STORED response
define("MC_ERR_GET_KEY", 1010); // _load_items no values returned for key(s)
define("MC_ERR_LOADITEM_END", 1011); // _load_items failed to receive END response
define("MC_ERR_LOADITEM_BYTES", 1012); // _load_items bytes read larger than bytes available
/**
* MemCached PHP client Class.
*
* Communicates with the MemCached server, and executes the MemCached protocol
* MemCached available at http://www.danga.com/memcached
*
* @author Ryan Gilfether <ryan@gilfether.com>
* @package MemCachedClient
* @access public
* @version 1.0.10
*/
class MemCachedClient
{
/**
* array of servers no long available
* @var array
*/
var $host_dead;
/**
* array of open sockets
* @var array
*/
var $cache_sock;
/**
* determine if debugging is either on or off
* @var bool
*/
var $debug;
/**
* array of servers to attempt to use, "host:port" string format
* @var array
*/
var $servers;
/**
* count of currently active connections to servers
* @var int
*/
var $active;
/**
* error code if one is set
* @var int
*/
var