【HTML5应用程序缓存ApplicationCache详解】教程文章相关的互联网学习教程文章

nginx缓存配置和ngx_cache_purge总结

nginx缓存配置首先设定一个cache日志的格式,可以在日志中查看“MISS”和“HIT”状态log_format cache ***$time_local ***$upstream_cache_status ***Cache-Control: $upstream_http_cache_control ***Expires: $upstream_http_expires ***"$request" ($status) ***"$http_user_agent";其次设定缓存参数proxy_connect_timeout 5;proxy_read_timeout 60;proxy_send_timeout 5;proxy_buffer_size 16k;proxy_buffers 4 64k;pro...

thinkPHP实现MemCache分布式缓存功能

本文实例讲述了thinkPHP实现MemCache分布式缓存功能。分享给大家供大家参考,具体如下:两天在研究MemCache分布式缓存的问题时,发现ThinkPHP其实并不支持分布式缓存功能,这可以从官方提供的CacheMemcache.class.php文件中看到:if(empty($options)) {$options = array(host => 127.0.0.1,port => 11211,timeout => false,persistent => false); } $func = $options[persistent] ? pconnect : connect; $this->expire = isset($op...

利用nginxproxy_cache进行网站缓存托底配置nginxfastcgicachenginxcache配置nginxfilecach

众所周知nginx proxy_cache可以对请求的response进行缓存,起到类CDN的作用,甚至有比CDN提供更多的功能,还可以用来缓存托底数据,当后台tomcat挂掉的时候,nginx直接将缓存中的托底数据返回给用户。直接贴上详细配置upstream tomcat_localhost {//注意此处超时时间不要设置太长server 127.0.0.1:8080 weight=10 max_fails=1 fail_timeout=1s;}1.nginx缓存空间配置,该配置定义在nginx配置文件的server上方即可#proxy_cache_path ...

memcachePHPMemCached高级缓存应用代码

Memcache常用方法 Memcache::add — 添加一个值,如果已经存在,则返回false Memcache::addServer — 添加一个可供使用的服务器地址 Memcache::close — 关闭一个Memcache对象 Memcache::connect — 创建一个Memcache对象 Memcache::debug — 控制调试功能 Memcache::decrement — 对保存的某个key中的值进行减法操作 Memcache::delete — 删除一个key值 Memcache::flush — 清除所有缓存的数据 Memcache::get — 获取一个key值 Me...

phpcache类代码php数据缓存类

如果访问量大的话会给数据库造成很大的负担,所以对于变化不经常的内容要做好php 数据cache(缓存)是十分必要的,我做了一个简单的php“文件缓存”的类,希望对大家有所帮助。 思路是这样的:对于一般的变量,把该变量变成php语言的格式,写到文件中,用时只要include这个文件就相当于加载了cache了; 对于array型的变量,把array转化为php语言定义array的字符串,写到文件中,用时也只要include就相当于加载了cache了; 缓存cache时...

MemcachedPHPMemcached+APC+文件缓存封装实现代码

使用方法: Memcached 代码如下:$cache = new Cache_MemCache(); $cache->addServer(www1); $cache->addServer(www2,11211,20); // this server has double the memory, and gets double the weight $cache->addServer(www3,11211); // Store some data in the cache for 10 minutes $cache->store(my_key,foobar,600); // Get it out of the cache again echo($cache->fetch(my_key)); 文件缓存 代码如下:$cache = new Cache_Fi...

Memcached同台服务器使用缓存APC效率高于Memcached的演示代码

代码如下:$memcachehost = 'localhost'; $memcacheport = '11211'; function microtime_float(){ list($usec, $sec) = explode(" ", microtime()); return ((float)$usec + (float)$sec); } function runtime($t1){ return number_format((microtime_float() - $t1)*1000, 4).'ms'; } $starttime = microtime_float(); $cache_time = '30'; echo "init=====".runtime($starttime).''; $sql = "SELECT * FROM hx WHERE id = 10006";...

PHP中加速、缓存扩展的区别和作用详解eAccelerator、memcached、xcache、APC

PHP中有eAccelerator、memcached、xcache、APC 4个加速、缓存扩展,下面给大家介绍下其区别,一起看看吧!  折腾VPS的朋友,在安装好LNMP等Web运行环境后都会选择一些缓存扩展安装以提高PHP运行速度,常被人介绍的有 eAccelerator、memcached、xcache、Alternative PHP Cache这几个缓存扩展,它们之间有什么区别?分别的作用又是什么?我们如何选择?这是本文给于大家的答案。1、eAccelerator  eAccelerator是一个自由开放源码PHP...

Joomla缓存Jcache

joomla 通过 Jcache缓存数据://调用Cache,参数'com_campaign'为缓存组,必须!$cache= JFactory::getCache('com_campaign',''); //设置:即使关闭全局缓存时,此缓存仍有效$cache->setCaching(true); //设置缓存时间,此处设置为 60s$cache->setLifeTime(60); //获取缓存$name=$cache->get('userid_101'); if(!$name){$str='my name is cache';//设置缓存$cache->store($str,'userid_101'); } echo '';print_r($name);exit; //移...

php写的一个缓存接口demo,兼容redis和memcache

/** * 工厂方法模式 * ------------- * @author zhangqian * @version v1.0 */ //缓存接口 interface cache { public function init($conf); public function setVal($key , $val); public function getVal($key); public function delVal($key); public function autoIncreament($key); } //mem class mymemCache implements cache { //...

PHP内存缓存memcached模块安装与用法

# tar -xzf libevent-1.1a.tar.gz # cd libevent-1.1a # ./configure --prefix=/usr # make # make install # cd .. # tar -xzf memcached-1.1.12.tar.gz # cd memcached-1.1.12 # ./configure --prefix=/usr # make # make install安装完成之后,memcached 应该在 /usr/bin/memcached。三、运行 memcached 守护程序运行 memcached 守护程序很简单,只需一个命令行即可,不需要修改任何配置文件(也没有配置文件给你修改):/usr/b...

php使用memcached缓存进行增删改查数据

//创建一个memcache对象实例$memcache = new Memcache;if(!$memcache->connect("127.0.0.1",11211)){ die('连接失败');}if($memcache->set('key1',"xian",MEMCACHE_COMPRESSED,60)){ echo 'sucess!';}//存值,其中xian字符串,也可以为数组,对象,但不能为资源// bbs.it-home.org$val = $memcache->get('key1');//查询获取值echo $val;$memcache->replace('key1','beijing',MEMCACHE_COMPRESSED,60);//修改$memcache->delete('key1...

thinkphpmemcache缓存用法示例

有关thinkphp中memcache的用法,包括memcache的安装、运行在ThinkPHP中如何使用,thinkphp 中memcache用作缓存的例子,需要的朋友参考下。 thinkphp中memcache缓存用法 1、下载并安装memcache1)、window下安装memcache. 下载memcached.exe 到d:/memcached/memcached.exe.在运行cmd 输入:d:/memcached/memcached.exe -d install安装 。2)、运行d:/memcached/memcached.exe -d start 启动memcache3)、下载php_memcache.dll 到php...

phpmemcached数据缓存入门例子

class mycache { private $cache; function __construct() { $this->cache = new memcache(); // you can replace localhost by memcached server ip addr and port no. $this->cache->connect('localhost', 10987); } // bbs.it-home.org function get_data($key) { $data = $this->cache->get($key); if($data != null) return $data; else { if($this->cache->getresult...

phpmemcached缓存类代码实例

class MemcacheModel { private $mc = null; /** * 构造方法,用于添加服务器并创建memcahced对象 */ function __construct(){ $params = func_get_args(); $mc = new Memcache; //如果有多个memcache服务器 if( count($params) > 1){ foreach ($params as $v){ call_user_func_array(array($mc, 'addServer'), $v); } //如果只有一个memcache服务器 } else { call_user_func_array(array($mc, 'addServer'), $params[0]); }$this->...