2017 © Pedro Peláez
 

library php_cache

cache

image

carler/php_cache

cache

  • Wednesday, April 4, 2018
  • by carler_czj
  • Repository
  • 1 Watchers
  • 0 Stars
  • 1 Installations
  • C++
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

php_cache

composer php cache, (*1)

使用方法:

1.下载

书写composer.json,内容如下:       {           "require":{       "carler/php_cache":"dev-master",
"php" : ">5.3.0" }, "minimum-stability":"dev" } , (*2)

2.然后执行composer install

3.CarlerCache\CCache($param,$cache_type)

例子: <?php require 'vendor/autoload.php';
use CarlerCache\CCache;
$config = [ 'file' => [ 'path' => '/tmp/' ] ]; $cache = new CCache($config['file'],'file'); , (*3)

$key = 'test'; $value = '12312312';
$ttl = 3; , (*4)

$ret = $cache->set($key, $value, $ttl); , (*5)

if ($ret != 0) { echo "set success, value is $value \nttl is $ttl \n";
} , (*6)

$ret = $cache->get($key);
if (!empty($ret)) { echo "get success , value is $ret \n";
} , (*7)

$ret = $cache->delete($key);
if (!file_exists($config['file']['path'] . $key)) {                     echo 'delete file success';                   } , (*8)

redis参数: $config = [
'redis' => [ 'host' => '127.0.0.1',
'port' => '9001', 'select' => '0', 'password' => 'redis123'
]
]; , (*9)

$cache = new CCache($config['redis'], 'redis'); , (*10)

ssdb参数: $config = [ 'ssdb' => [ 'host' => '127.0.0.1', 'port' => '8888', 'password' => '1234567890qwertyuiopasdfghjklzxcvbnm'
] ]; , (*11)

$cache = new CCache($config['ssdb'], 'ssdb'); , (*12)

然后调用方式:

$cache->get($key); //获取key值
$cache->set($key, $val, $ttl);; //设置key 的value值 ttl是有效期 时间为秒,默认360s $cache->delete($key) ; //删除key值 , (*13)

The Versions

04/04 2018

dev-master

9999999-dev

cache

  Sources   Download

MIT

The Requires

  • php >5.3.0

 

by carler