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)
{
[laravel]使用redis实现全局缓存(global cache)
最新推荐文章于 2024-01-18 20:15:00 发布
本文详细介绍了如何在Laravel框架中利用Redis作为全局缓存解决方案,包括配置、使用方法及优化技巧,旨在提升应用性能。

最低0.47元/天 解锁文章
1万+

被折叠的 条评论
为什么被折叠?



