Package Data | |
---|---|
Maintainer Username: | deathkel |
Package Create Date: | 2017-04-13 |
Package Last Update: | 2018-07-16 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2025-02-06 03:07:55 |
Package Statistics | |
---|---|
Total Downloads: | 32 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 11 |
Total Watchers: | 3 |
Total Forks: | 0 |
Total Open Issues: | 0 |
composer require deathkel/easy-cache
static
variable $expire
for each functionpublic class test(){
use EasyCacheTrait;
public function __construct(){
$this->default_expire = 1; //change default expire time (min)
}
public function DontWantToBeCache(){ // public function will not be cached
//.....
}
protected function WantToBeCache(){ // protected function will be cached automatically
static $expire = 60; //minute that this function want to be cached
}
private static function _getCacheKeyPrefixLevel1(){
return "test:"; //overwrite cache prefix level 1, default is class name
}
private static function _getCacheKeyPrefixLevel2($method){
return self::_getCacheKeyPrefixLevel1() . $method . ":"; //overwrite cache prefix level 2
}
private static function _getCacheKey($method, $params){
return self::_getCacheKeyPrefixLevel2($method) . md5(json_encode($params)); //overwrite cache key
}
}
forgetCache
to delete all cache in classforgetMethodCache
to delete all cache in the methodThe MIT License (MIT). Please see License File for more information.