热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

求问哪里有PHPmemcached的学习资料,该如何处理

后端开发|php教程nbsp,memcache,the,server,protected后端开发-php教程求问哪里有PHPmemcached的学习资料本来应届毕业生一枚,想要学习

后端开发|php教程求问哪里有PHP memcached的学习资料,该如何处理
nbsp,memcache,the,server,protected
后端开发-php教程
求问哪里有PHP memcached的学习资料
本来应届毕业生一枚,想要学习一下memcached,已经搭建好了环境,可惜找不到PHP memcached具体的学习资料,
PHP手册上的十分不全,求大神介绍网址或者资料谢谢~
——解决思路———————-
云空间源码下载,ubuntu远程关闭进程,tomcat如何外接浏览器,python爬虫职业,php开发教程后端技术外包,谷歌seo意思lzw


/**
* CMemCache class file
*
* @author Qiang Xue
* @link http://www.yiiframework.com/
* @copyright 2008-2013 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
/**
* CMemCache implements a cache application component based on [email protected] http://memcached.org/ memcached}.
*
* CMemCache can be configured with a list of memcache servers by settings
* its [email protected] setServers servers} property. By default, CMemCache assumes
* there is a memcache server running on localhost at port 11211.
*
* See [email protected] CCache} manual for common cache operations that are supported by CMemCache.
*
* Note, there is no security measure to protected data in memcache.
* All data in memcache can be accessed by any process running in the system.
*
* To use CMemCache as the cache application component, configure the application as follows,
*


* array(
* 'components'=>array(
* 'cache'=>array(
* 'class'=>'CMemCache',
* 'servers'=>array(
* array(
* 'host'=>'server1',
* 'port'=>11211,
* 'weight'=>60,
* ),
* array(
* 'host'=>'server2',
* 'port'=>11211,
* 'weight'=>40,
* ),
* ),
* ),
* ),
* )
*

* In the above, two memcache servers are used: server1 and server2.
* You can configure more properties of every server, including:
* host, port, persistent, weight, timeout, retryInterval, status.
* See [email protected] http://www.php.net/manual/en/function.memcache-addserver.php}
* for more details.
*
* CMemCache can also be used with [email protected] http://pecl.php.net/package/memcached memcached}.
* To do so, set [email protected] useMemcached} to be true.
*
* @property mixed $memCache The memcache instance (or memcached if [email protected] useMemcached} is true) used by this component.
* @property array $servers List of memcache server configurations. Each element is a [email protected] CMemCacheServerConfiguration}.
*
* @author Qiang Xue
* @package system.caching
* @since 1.0
*/
class CMemCache extends CCache
{
/**
* @var boolean whether to use memcached or memcache as the underlying caching extension.
* If true [email protected] http://pecl.php.net/package/memcached memcached} will be used.
* If false [email protected] http://pecl.php.net/package/memcache memcache}. will be used.
* Defaults to false.
*/
public $useMemcached=false;
/**
* @var Memcache the Memcache instance
*/
private $_cache=null;
/**
* @var array list of memcache server configurations
*/
private $_servers=array();

网站源码解密,vscode怎么改字体格式,ubuntu流畅版,Tomcat不支持idl,爬虫实际用途,ionic2 php,网站seo推广开场白lzw
/**
* Initializes this application component.
* This method is required by the [email protected] IApplicationComponent} interface.
* It creates the memcache instance and adds memcache servers.
* @throws CException if memcache extension is not loaded
*/
public function init()
{
parent::init();
$servers=$this->getServers();
$cache=$this->getMemCache();
if(count($servers))
{
foreach($servers as $server)
{
if($this->useMemcached)
$cache->addServer($server->host,$server->port,$server->weight);
else
$cache->addServer($server->host,$server->port,$server->persistent,$server->weight,$server->timeout,$server->retryInterval,$server->status);
}
}
else
$cache->addServer('localhost',11211);
}
活动会整站源码下载,ubuntu的man命令,scrapy爬虫 数据分类,php iisc,seo门户 sitelzw
/**
* @throws CException if extension isn't loaded
* @return Memcache
------解决思路----------------------
Memcached the memcache instance (or memcached if [email protected] useMemcached} is true) used by this component.
*/
public function getMemCache()
{
if($this->_cache!==null)
return $this->_cache;
else
{
$extension=$this->useMemcached ? 'memcached' : 'memcache';
if(!extension_loaded($extension))
throw new CException(Yii::t('yii',"CMemCache requires PHP {extension} extension to be loaded.",
array('{extension}'=>$extension)));
return $this->_cache=$this->useMemcached ? new Memcached : new Memcache;
}
}

/**
* @return array list of memcache server configurations. Each element is a [email protected] CMemCacheServerConfiguration}.
*/
public function getServers()
{
return $this->_servers;
}

/**
* @param array $config list of memcache server configurations. Each element must be an array
* with the following keys: host, port, persistent, weight, timeout, retryInterval, status.
* @see http://www.php.net/manual/en/function.Memcache-addServer.php
*/
public function setServers($config)
{
foreach($config as $c)
$this->_servers[]=new CMemCacheServerConfiguration($c);
}

/**
* Retrieves a value from cache with a specified key.
* This is the implementation of the method declared in the parent class.
* @param string $key a unique key identifying the cached value
* @return string
------解决思路----------------------
boolean the value stored in cache, false if the value is not in the cache or expired.
*/
protected function getValue($key)
{
return $this->_cache->get($key);
}

/**
* Retrieves multiple values from cache with the specified keys.
* @param array $keys a list of keys identifying the cached values
* @return array a list of cached values indexed by the keys
*/
protected function getValues($keys)
{
return $this->useMemcached ? $this->_cache->getMulti($keys) : $this->_cache->get($keys);
}

/**
* Stores a value identified by a key in cache.
* This is the implementation of the method declared in the parent class.
*
* @param string $key the key identifying the value to be cached
* @param string $value the value to be cached
* @param integer $expire the number of seconds in which the cached value will expire. 0 means never expire.
* @return boolean true if the value is successfully stored into cache, false otherwise
*/
protected function setValue($key,$value,$expire)
{
if($expire>0)
$expire+=time();
else
$expire=0;

return $this->useMemcached ? $this->_cache->set($key,$value,$expire) : $this->_cache->set($key,$value,0,$expire);
}

/**
* Stores a value identified by a key into cache if the cache does not contain this key.
* This is the implementation of the method declared in the parent class.
*
* @param string $key the key identifying the value to be cached
* @param string $value the value to be cached
* @param integer $expire the number of seconds in which the cached value will expire. 0 means never expire.
* @return boolean true if the value is successfully stored into cache, false otherwise
*/
protected function addValue($key,$value,$expire)
{
if($expire>0)
$expire+=time();
else
$expire=0;

return $this->useMemcached ? $this->_cache->add($key,$value,$expire) : $this->_cache->add($key,$value,0,$expire);
}

/**
* Deletes a value with the specified key from cache
* This is the implementation of the method declared in the parent class.
* @param string $key the key of the value to be deleted
* @return boolean if no error happens during deletion
*/
protected function deleteValue($key)
{
return $this->_cache->delete($key, 0);
}

/**
* Deletes all values from cache.
* This is the implementation of the method declared in the parent class.
* @return boolean whether the flush operation was successful.
* @since 1.1.5
*/
protected function flushValues()
{
return $this->_cache->flush();
}
}

/**
* CMemCacheServerConfiguration represents the configuration data for a single memcache server.
*
* See [email protected] http://www.php.net/manual/en/function.Memcache-addServer.php}
* for detailed explanation of each configuration property.
*
* @author Qiang Xue
* @package system.caching
* @since 1.0
*/
class CMemCacheServerConfiguration extends CComponent
{
/**
* @var string memcache server hostname or IP address
*/
public $host;
/**
* @var integer memcache server port
*/
public $port=11211;
/**
* @var boolean whether to use a persistent connection
*/
public $persistent=true;
/**
* @var integer probability of using this server among all servers.
*/
public $weight=1;
/**
* @var integer value in seconds which will be used for connecting to the server
*/
public $timeout=15;
/**
* @var integer how often a failed server will be retried (in seconds)
*/
public $retryInterval=15;
/**
* @var boolean if the server should be flagged as online upon a failure
*/
public $status=true;

/**
* Constructor.
* @param array $config list of memcache server configurations.
* @throws CException if the configuration is not an array
*/
public function __construct($config)
{
if(is_array($config))
{
foreach($config as $key=>$value)
$this->$key=$value;
if($this->host===null)
throw new CException(Yii::t('yii','CMemCache server configuration must have "host" value.'));
}
else
throw new CException(Yii::t('yii','CMemCache server configuration must be an array.'));
}
}

贴个YII的cache类 继承的CCache可以不管 默认实现CRUD4个方法。。自己百度下 就是add个值 在get就行 别想太复杂
------解决思路----------------------
这个看PHP手册吧,其实用得取多的是get set replace delete 重点看看就可以了.


推荐阅读
  • 如何实现织梦DedeCms全站伪静态
    本文介绍了如何通过修改织梦DedeCms源代码来实现全站伪静态,以提高管理和SEO效果。全站伪静态可以避免重复URL的问题,同时通过使用mod_rewrite伪静态模块和.htaccess正则表达式,可以更好地适应搜索引擎的需求。文章还提到了一些相关的技术和工具,如Ubuntu、qt编程、tomcat端口、爬虫、php request根目录等。 ... [详细]
  • PHPMailer邮件类邮件发送功能的使用教学及注意事项
    本文介绍了使用国外开源码PHPMailer邮件类实现邮件发送功能的简单教学,同时提供了一些注意事项。文章涵盖了字符集设置、发送HTML格式邮件、群发邮件以及避免类的重定义等方面的内容。此外,还提供了一些与PHP相关的资源和服务,如传奇手游游戏源码下载、vscode字体调整、数据恢复、Ubuntu实验环境搭建、北京爬虫市场、进阶PHP和SEO人员需注意的内容。 ... [详细]
  • MySQL语句大全:创建、授权、查询、修改等【MySQL】的使用方法详解
    本文详细介绍了MySQL语句的使用方法,包括创建用户、授权、查询、修改等操作。通过连接MySQL数据库,可以使用命令创建用户,并指定该用户在哪个主机上可以登录。同时,还可以设置用户的登录密码。通过本文,您可以全面了解MySQL语句的使用方法。 ... [详细]
  • 分享css中提升优先级属性!important的用法总结
    web前端|css教程css!importantweb前端-css教程本文分享css中提升优先级属性!important的用法总结微信门店展示源码,vscode如何管理站点,ubu ... [详细]
  • PHP函数实现分页含文本分页和数字分页【PHP】
    后端开发|php教程PHP,分页后端开发-php教程最近,在项目中要用到分页。分页功能是经常使用的一个功能,所以,对其以函数形式进行了封装。影视网源码带充值系统,vscode配置根 ... [详细]
  • mui框架offcanvas侧滑超出部分隐藏无法滚动如何解决
    web前端|js教程off-canvas,部分,超出web前端-js教程mui框架中off-canvas侧滑的一个缺点就是无法出现滚动条,因为它主要用途是设置类似于qq界面的那种格 ... [详细]
  • Linux下部署Symfoy2对app/cache和app/logs目录的权限设置,symfoy2logs
    php教程|php手册xml文件php教程-php手册Linux下部署Symfoy2对appcache和applogs目录的权限设置,symfoy2logs黑色记事本源码,vsco ... [详细]
  • Oracle 和 mysql的9点区别【MySQL】
    数据库|mysql教程oracle,Oracle,money,mysql,coun数据库-mysql教程1.组函数用法规则mysql中组函数在select语句中可以随意使用,但在o ... [详细]
  • ORACLE空间管理实验5:块管理之ASSM下高水位的影响
    数据库|mysql教程ORACLE,空间,管理,实验,ASSM,下高,水位,影响,数据库-mysql教程易语言黑客软件源码,vscode左侧搜索,ubuntu怎么看上一页,ecs搭 ... [详细]
  • PHP输出缓冲控制Output Control系列函数详解【PHP】
    后端开发|php教程PHP,输出缓冲,Output,Control后端开发-php教程概述全景网页源码,vscode如何打开c,ubuntu强制解锁,sts启动tomcat慢,sq ... [详细]
  • 用PHP连接MySQL代码的参数说明【PHP】
    后端开发|php教程PHP,连接,MySQL,参数后端开发-php教程代码是这样的:大图标网站源码,怎么在vscode中调试css,ubuntu退出命令行,系统默认开tomcat, ... [详细]
  • 电脑f5键是什么作用
    常见问题f5常见问题韩亚整形医院源码,vscode写前端代码,ubuntu低配,tomcat下载路径乱码,爬虫_gscu,php精粹pdf,广州快速seo优化排名,aspwap网站 ... [详细]
  • Php怎么编写乘法表
    后端开发|PHP问题php,乘法表后端开发-PHP问题传世登陆器源码,vscode设置字号,ubuntu系统创建不了文件,tomcat配置修改,sqlite怎么调中文,海洋采集插件 ... [详细]
  • 通过手机浏览器调用客户端QQ
    php教程|php手册thinkphp代码,代码示例,代码参考,php短信,数据库备份代码,令牌验证,去除代码中的空白和注释调用QQ客户端php教程-php手册可调用iosandr ... [详细]
  • 31.项目部署
    目录1一些概念1.1项目部署1.2WSGI1.3uWSGI1.4Nginx2安装环境与迁移项目2.1项目内容2.2项目配置2.2.1DEBUG2.2.2STAT ... [详细]
author-avatar
6易0k醉人也s易
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有