whereof/cache

独立cache缓存SDK,支持file,Redis,Memcache,Memcached等驱动

1.0.1 2021-11-22 06:20 UTC

This package is auto-updated.

Last update: 2021-11-22 06:27:08 UTC


README

$config =  [
  'expire'        => 0,
  'cache_subdir'  => true,
  'prefix'        => '',
  'path'          => './.cache',
  'hash_type'     => 'md5',
  'data_compress' => false,
];
$cache = (new CacheManager())->driver('file',$config);
$cache = \whereof\Cache\CacheManager::File($config)

Redis

$config = [
    'host'       => '127.0.0.1',
    'port'       => 6379,
    'password'   => '',
    'select'     => 0,
    'timeout'    => 0,
    'expire'     => 0,
    'persistent' => false,
    'prefix'     => '',
]
$cache = (new CacheManager())->driver('redis',$config);
$cache = \whereof\Cache\CacheManager::Redis($config)

Memcache

$config = [
    'host'       => '127.0.0.1',
    'port'       => 11211,
    'expire'     => 0,
    'timeout'    => 0, // 超时时间(单位:毫秒)
    'persistent' => true,
    'prefix'     => '',
];
$cache = (new CacheManager())->driver('memcache', $config);
$cache = \whereof\Cache\CacheManager::Memcache($config);

Memcached

 $config = [
    'host'     => '127.0.0.1',
    'port'     => 11211,
    'expire'   => 0,
    'timeout'  => 0, // 超时时间(单位:毫秒)
    'prefix'   => '',
    'username' => '', //账号
    'password' => '', //密码
    'option'   => [],
]
$cache = (new CacheManager())->driver('memcached',$config);
$cache = \whereof\Cache\CacheManager::Memcached($config);

PDO

//自定义:name字段
\whereof\Cache\Driver\Pdo::$table_field_key='key';
//自定义:value字段
\whereof\Cache\Driver\Pdo::$table_field_value='vaule';
//自定义:expire过期时间字段
\whereof\Cache\Driver\Pdo::$table_field_expire='expire';
$config =  [
     'dns'      => 'mysql:host=127.0.0.1;dbname=cache',
     'username' => 'root',
     'passwd'   => '123456'
];
$cache = (new CacheManager())->driver('pdo',$config);
$cache = \whereof\Cache\CacheManager::Pdo($config);