php的两个memcached扩展 memcache…
来源:互联网 发布:deepin linux 15.4.1 编辑:程序博客网 时间:2024/06/05 00:36
现在在php中memcached用的很多,以前一直使用的是php的memcache扩展,最近开始改用了php的memcached扩展(注意这里memcache和memcached扩展的名字就相差了一个d)。或许在google或者百度搜索php的memcached扩展的时候,很多结果是memcache.dll或者memcache.so,很少的结果是memcached.so,windows下面甚至没有memcached.dll扩展。
memcache扩展的下载地址为:http://pecl.php.net/package/memcache
memcached扩展的下载地址为:http://pecl.php.net/package/memcached
以上两个都是源码包。
这两个扩展都是用c写的,具体的来看看memcache扩展和memcached扩展在使用上到底有哪些差别。
加载memcache扩展之后,可以在php中直接使用Memcache类,Memcache类有以下一些方法:
[php] view plaincopy
- Memcache
{ -
bool add ( string $key , $varmixed [, $flagint [, $expireint ]] ) -
-
bool addServer ( string $host [, $portint = $persistent11211 [, bool [, $weightint [, $timeoutint [, $retry_intervalint [, $statusbool [, $failure_callbackcallback [, $timeoutmsint ]]]]]]]] ) -
-
bool close ( void ) -
-
bool connect ( string $host [, $portint [, $timeoutint ]] ) -
-
int decrement ( string $key [, $valueint = 1 ] ) -
-
bool delete ( $keystring [, $timeoutint ] ) -
-
bool flush ( void ) -
-
string get ( string $key [, $flagsint & ] ) -
-
array getExtendedStats $type([ string [, $slabidint [, $limitint = 100 ]]] ) -
-
int getServerStatus ( string $host [, $portint = 11211 ] ) -
-
array getStats $type([ string [, $slabidint [, $limitint = 100 ]]] ) -
-
string getVersion ( void ) -
-
int increment ( string $key [, $valueint = 1 ] ) -
-
bool pconnect ( string $host [, $portint [, $timeoutint ]] ) -
-
bool replace ( string $key , $varmixed [, $flagint [, $expireint ]] ) -
-
bool set ( string $key , $varmixed [, $flagint [, $expireint ]] ) -
-
bool setCompressThreshold ( int $threshold [, $min_savingsfloat ] ) -
-
bool setServerParams ( string $host [, $portint = $timeout11211 [, int [, $retry_intervalint = $statusfalse [, bool [, $failure_callbackcallback ]]]]] ) - }
[php] view plaincopy
- add
— 增加一个条目到缓存服务器 - addServer
— 向连接池中添加一个memcache服务器 - close
— 关闭memcache连接 - connect
— 打开一个memcached服务端连接 - decrement
— 减小元素的值 - delete
— 从服务端删除一个元素 - flush
— 清洗(删除)已经存储的所有的元素 - get
— 从服务端检回一个元素 - getExtendedStats
— 缓存服务器池中所有服务器统计信息 - getServerStatus
— 用于获取一个服务器的在线/离线状态 - getStats
— 获取服务器统计信息 - getVersion
— 返回服务器版本信息 - increment
— 增加一个元素的值 - pconnect
— 打开一个到服务器的持久化连接 - replace
— 替换已经存在的元素的值 - set
— Store data at the server - setCompressThreshold
— 开启大值自动压缩 - setServerParams
— 运行时修改服务器参数和状态
加载memcached扩展之后,可以在php中直接使用Memcached类,Memcached类有以下一些方法:
[php] view plaincopy
- Memcached
{ -
__construct ([ string $persistent_id ] ) -
-
public bool $keyadd ( string , $valuemixed [, $expirationint ] ) -
-
public bool $server_keyaddByKey ( string , $keystring , $valuemixed [, $expirationint ] ) -
-
public bool $hostaddServer ( string , $portint [, $weightint = 0 ] ) -
-
public bool arrayaddServers ( $servers ) -
-
public bool $keyappend ( string , $valuestring ) -
-
public bool $server_keyappendByKey ( string , $keystring , $valuestring ) -
-
public bool $cas_tokencas ( float , $keystring , $valuemixed [, $expirationint ] ) -
-
public bool $cas_tokencasByKey ( float , $server_keystring , $keystring , $valuemixed [, $expirationint ] ) -
-
public int $keydecrement ( string [, $offsetint = 1 ] ) -
-
public bool delete( $keystring [, $timeint = 0 ] ) -
-
public bool $server_keydeleteByKey ( string , $keystring [, $timeint = 0 ] ) -
-
public array fetch ( void ) -
-
public array fetchAll ( void ) -
-
public bool flush([ $delayint = 0 ] ) -
-
public mixed $keyget ( string [, $cache_cbcallback [, $cas_tokenfloat & ]] ) -
-
public mixed $server_keygetByKey ( string , $keystring [, $cache_cbcallback [, $cas_tokenfloat & ]] ) -
-
public bool arraygetDelayed ( $keys [, $with_casbool [, $value_cbcallback ]] ) -
-
public bool $server_keygetDelayedByKey ( string , array$keys [, $with_casbool [, $value_cbcallback ]] ) -
-
public mixed arraygetMulti ( $keys [, array& $cas_tokens[, $flagsint ]] ) -
-
public array getMultiByKey $server_key( string , array$keys [, $cas_tokensstring & [, $flagsint ]] ) -
-
public mixed $optiongetOption ( int ) -
-
public int getResultCode ( void ) -
-
public string getResultMessage ( void ) -
-
public array getServerByKey $server_key( string ) -
-
public array getServerList ( void ) -
-
public array getStats ( void ) -
-
public array getVersion ( void ) -
-
public int $keyincrement ( string [, $offsetint = 1 ] ) -
-
public bool $keyprepend ( string , $valuestring ) -
-
public bool $server_keyprependByKey ( string , $keystring , $valuestring ) -
-
public bool $keyreplace ( string , $valuemixed [, $expirationint ] ) -
-
public bool $server_keyreplaceByKey ( string , $keystring , $valuemixed [, $expirationint ] ) -
-
public bool $keyset ( string , $valuemixed [, $expirationint ] ) -
-
public bool $server_keysetByKey ( string , $keystring , $valuemixed [, $expirationint ] ) -
-
public bool arraysetMulti ( $items [, $expirationint ] ) -
-
public bool $server_keysetMultiByKey ( string , array$items [, $expirationint ] ) -
-
public bool $optionsetOption ( int , $valuemixed )
[php] view plaincopy
- add
— 向一个新的key下面增加一个元素 - addByKey
— 在指定服务器上的一个新的key下增加一个元素 - addServer
— 向服务器池中增加一个服务器 - addServers
— 向服务器池中增加多台服务器 - append
— 向已存在元素后追加数据 - appendByKey
— 向指定服务器上已存在元素后追加数据 - cas
— 比较并交换值 - casByKey
— 在指定服务器上比较并交换值 - __construct
— 创建一个Memcached实例 - decrement
— 减小数值元素的值 - delete
— 删除一个元素 - deleteByKey
— 从指定的服务器删除一个元素 - fetch
— 抓取下一个结果 - fetchAll
— 抓取所有剩余的结果 - flush
— 作废缓存中的所有元素 - get
— 检索一个元素 - getByKey
— 从特定的服务器检索元素 - getDelayed
— 请求多个元素 - getDelayedByKey
— 从指定的服务器上请求多个元素 - getMulti
— 检索多个元素 - getMultiByKey
— 从特定服务器检索多个元素 - getOption
— 获取Memcached的选项值 - getResultCode
— 返回最后一次操作的结果代码 - getResultMessage
— 返回最后一次操作的结果描述消息 - getServerByKey
— 获取一个key所映射的服务器信息 - getServerList
— 获取服务器池中的服务器列表 - getStats
— 获取服务器池的统计信息 - getVersion
— 获取服务器池中所有服务器的版本信息 - increment
— 增加数值元素的值 - prepend
— 向一个已存在的元素前面追加数据 - prependByKey
— Prepend data to an existing item on a specific server - replace
— 替换已存在key下的元素 - replaceByKey
— Replace the item under an existing key on a specific server - set
— 存储一个元素 - setByKey
— Store an item on a specific server - setMulti
— 存储多个元素 - setMultiByKey
— Store multiple items on a specific server - setOption
— 设置一个memcached选项
- php的两个memcached扩展 memcache…
- PHP的两个memcache扩展 memcache和…
- PHP 的两个 memcache 扩展:memcache 和 memcached(一)
- PHP 的两个 memcache 扩展:memcache 和 memcached
- php的两个memcached扩展:memcache和memcached
- php的两个memcached扩展:memcache和memcached(二)
- PHP扩展memcache与memcached的区别
- PHP扩展memcache和memcached的区别
- php的memcache和memcached扩展区别
- php扩展Memcache和Memcached的区别
- php的memcache和memcached扩展区别
- php的memcache和memcached扩展区别
- php的memcache和memcached扩展区别
- CI memcached.php 兼容 memcache,memcached扩展
- 编译安装libevent,memcache,以及php的memcached扩展
- 关于Windows7 下面安装memcached和php的memcache扩展
- 编译安装libevent,memcache,以及php的memcached扩展
- CentOS安装memcached及配置php的memcache扩展
- 模板引擎详解:导入资源文件
- 使用awk合并文件--生成report
- Memcached深度分析
- Windows安装memcached图文教程
- PHP的两个memcache扩展 memcache和…
- php的两个memcached扩展 memcache…
- php操作memcache的使用总结(1)
- php操作memcache的使用总结(2)
- ThinkPHP3.1快速入门(12)自动验…
- 网页设计中常用的19个Web安全字体
- CSS3 box-shadow Property
- u-boot1.3.4
- CSS3 background-size Property
- 链表和队列复习