小编dev*_*ect的帖子

PHP PEAR Cache_Lite

你好。

由于我使用的是共享托管包,并且无法使用 PECL Memcache,因此我希望能提供一些有关使用我自己的小型缓存系统或使用 PEAR Cache_Lite 系统之间的疑虑的提示。

所以这是我的功能:

<?php

//this one create a simple .txt file named by unique query_key string generated width e.g $file_name=md5("SELECT * FROM table"); content of that file is serialized value of mysql return

function write($query_key,$result)
{
  global $config;
  $new_file_name=md5($query_key);
  $result_to_write=serialize($result);  
  if($handle=opendir($config['cache_dir'])) 
  {
    $f=fopen($config['cache_dir'].$new_file_name.'.txt','w+');
    fwrite($f,$result_to_write);        
    fclose($f);
    closedir($handle);
  }
}

// this one reads content of file (serialized mysql return of unique query_key) if timeout hes not expired, and if it is it return false

function read($query_key,$timeout) …
Run Code Online (Sandbox Code Playgroud)

php pear memcached

2
推荐指数
1
解决办法
1254
查看次数

标签 统计

memcached ×1

pear ×1

php ×1