yggverse / cache
PHP应用程序的缓存工具
0.4.1
2024-02-02 23:00 UTC
Requires
- php: >=8.1
README
PHP应用程序的缓存工具
内存
初始化
$memory = new \Yggverse\Cache\Memory(
'localhost', // memcached server host, localhost by default
11211, // memcached server port, 11211 by default
'my_app', // application namespace
3600 + time() // cache time by default
);
支持的方法
Memory::set
Memory::delete
Memory::flush
Memory::get
Memory::getByValueCallback
返回缓存的或缓存新值的纯值回调函数
$value = $memory->getByValueCallback(
'key_name', // string, unique key name
'value', // mixed, plain value
3600 + time(), // optional, cache timeout for this value
);
Memory::getByMethodCallback
返回缓存的或缓存新值的对象方法回调函数
$value = $memory->getByMethodCallback(
$class_object, // object of method class
'method_name', // object method name
[
$method_attribute_1, // optional, array of attributes callback method requires
$method_attribute_2,
...
]
3600 + time(), // optional, cache timeout for this value
);