2017 © Pedro Peláez
 

library cache

数据缓存

image

hutong/cache

数据缓存

  • Friday, May 11, 2018
  • by HuTong
  • Repository
  • 1 Watchers
  • 0 Stars
  • 198 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 53 % Grown

The README.md

cache

数据缓存, (*1)

配置

File 缓存

include './vendor/autoload.php';

$config = array(
    'default' => array(
        'type' => 'File',
        'path' => '/var/www/test/cache/',
        'prefix' => '',
    ),
    'redis' => array(
        'type' => 'Redis',
        'host' => '127.0.0.1',
        'port' => '6379',
        'password' => '123456',
        'prefix' => 'web.',
    ),
);

$cache = new HuTong\Cache\Storage($config);

$val = $cache->store()->increment('getVal');
var_dump($val);
$val = $cache->store('redis')->increment('getVal');
var_dump($val);

输出:
int(1)
int(1)
$val = $cache->store()->set('getVal','33');

$val = $cache->store()->get('getVal');

3分钟过期
$val = $cache->store()->expire('getVal',33);

33秒钟过期
$val = $cache->store()->expire('getVal',33,1);

$val = $cache->store()->del('getVal');

$val = $cache->store()->increment('getVal');

$val = $cache->store()->decrement('getVal');

$val = $cache->store()->flush();

学习交流群

630730920, (*2)

The Versions

11/05 2018

dev-master

9999999-dev

数据缓存

  Sources   Download

MIT

The Requires

  • php >=7.0.0

 

by Avatar HuTong