anoxgh/simplecache

dev-master 2015-05-30 08:37 UTC

This package is not auto-updated.

Last update: 2024-10-02 07:55:47 UTC


README

安装

通过 composer 安装

{
    "require": {
        "anoxgh/simplecache": "dev-master"
    }
}

运行 composer install 然后按常规使用

用法

$fileCache = new AnoxGH\SimpleCache\FileCache('Temporary/FileCache');
$fileCache->set('CacheKey', 'ExampleValue', 360);
var_dump($fileCache->get('CacheKey'));

$fileCache->flush('CacheKey');


$sessionCache = new AnoxGH\SimpleCache\SessionCache();
$sessionCache->set('CacheKey', 'ExampleValue', 360);

var_dump($sessionCache->get('CacheKey'));

$sessionCache->flush('CacheKey');

$apcCache = new AnoxGH\SimpleCache\ApcCache();
$apcCache->set('CacheKey', 'ExampleValue', 360);
var_dump($apcCache->get('CacheKey'));

$apcCache->flush('CacheKey');

$memoryCache = new AnoxGH\SimpleCache\MemoryCache();
$memoryCache->set('CacheKey', 'ExampleValue', 360);
var_dump($memoryCache->get('CacheKey'));

$memoryCache->flush('CacheKey');

$memCacheServer = array(
            array('127.0.0.1', 7000, 10),
            array('127.0.0.2', 7000, 20));

$memCache = new AnoxGH\SimpleCache\MemCache($memCacheServer);
$memCache->set('CacheKey', 'ExampleValue', 360);
var_dump($memCache->get('CacheKey'));

$memCache->flush('CacheKey');

致谢

PHP SimpleCache 由 Sebastian Gieselmann 创建。在 GPL-2.0 许可下发布。