class GlobalCache
{
/**
* @return Repository
*/
public static function getCurrentStore()
{
/** @noinspection PhpUndefinedMethodInspection */
$defaultDriver = Cache::getDefaultDriver();
if (config("cache.stores.$defaultDriver.driver") === 'redis') {
$store = Cache::store('global_redis');
} else {
$store = Cache::store('array');
}
return $store;
}
/**
* @param $tags
* @return \Illuminate\Cache\TaggedCache
*/
public static function tags($tags)
{
return self::getCurrentStore()->tags($tags);
}
/**
* @param string $key
* @return object
*/
public static function get($key)
{
return self::getCurrentStore()->get($key);
}
/**
* @param string $key
* @param string $value
* @param string $minutes
*/
public static function put($key, $value, $minutes)
{
self::getCurrentStore()->put($key, $value, $minutes);
}
使用: