gsferro/autocacheeasy

此包已被废弃,不再维护。未建议替代包。

用于在 Laravel 中以简单方式执行 Redis 的自动缓存

dev-main 2021-05-10 04:44 UTC

This package is auto-updated.

Last update: 2021-12-27 20:39:25 UTC


README

EN

  • 用于在 Laravel 中以简单方式执行 Redis 的自动缓存
  • 此包受到 amitavroy/rediscache 的启发,并内部使用它

PT-BR

  • Pacote para realizar o autocache de uma forma easy no Laravel com Redis
  • Este pacote foi inspirado no amitavroy/rediscache e o usa internamente

安装

composer require gsferro/autocacheeasy

依赖

"predis/predis": "^1.1",

使用

  • 全局实例 autocacheeasy()
/**
* Package instance
* Instancia do pacote
*
* @param string $keyPrefix default null, 
* @param string $keyPrefixSeparetor default ':' 
* @return AutoCacheEasyService
*/
$autocacheeasy = autocacheeasy();
  • 别名 autocache()
/**
* Alias small for autocacheeasy().
*
* @return Gsferro\AutoCacheEasy\Services\AutoCacheEasyService
*/
$autocache = autocache();
  • 记住方法
autocacheeasy()->remember(string $key, $ttl, \Closure $callback)
  • 永远记住方法
autocacheeasy()->remember(string $key, $ttl, \Closure $callback)
  • 检索方法
autocacheeasy()->retriver(string $key, \Closure $callback, $all = false)

方法包启发/依赖

EN

  • 使用此包,您仍然保留所有依赖包的功能。

PT-BR

  • Ao usar este pacote, você ainda mantém todas as funções do pacote de dependência.
方法包依赖 \Illuminate\Cache\CacheManager

EN

  • 直接访问缓存

PT-BR

  • Para ter acesso ao cache diretamente
autocacheeasy()->cache
方法包依赖 predis/predis

EN

  • 直接访问 predis

PT-BR

  • Para ter acesso ao predis diretamente
autocacheeasy()->redis
方法包启发 amitavroy/rediscache
autocacheeasy()->get($key) 

autocacheeasy()->set($key, $value) 

autocacheeasy()->getAll($key) 

autocacheeasy()->forget($key, $wildcard = false) 

ResponseView

EN

  • 从视图中轻松获取日期
  • 在您的控制器中添加 Trait ResponseViewCache

PT-BR

/**
* Easily add an item to ResponseView :: $ data and cache it
* Adicionar forma fácil um item ao ResponseView::$data e coloca no cache
*
* @param string $key
* @param callable $value
* @param int $time 60
*/
$this->addDataCache(string $key, callable value, int $time 60)
  • 方法 addMergeDataCache
/**
* Easily add an item to ResponseView::$mergeData and cache it
* Adicionar forma fácil um item ao ResponseView::$mergeData e coloca no cache
*
* @param string $key
* @param callable $value
* @param int $time 60
*/
$this->addMergeDataCache(string $key, callable value, int $time 60)
  • 方法 addDataOtherKeyCache
/**
* Easily add an item to ResponseView::$data and cache it
* Adicionar forma fácil um item ao ResponseView::$data e coloca no cache
*
* @param string $key
* @param string $keyCache
* @param callable $value
* @param int $time 60
*/
$this->addDataOtherKeyCache( string $key, string $keyCache, callable value, int $time 60 )
  • 方法 addMergeDataOtherKeyCache
/**
* Easily add an item to ResponseView::$mergeData and cache it
* Adicionar forma fácil um item ao ResponseView::$mergeData e coloca no cache
*
* @param string $key
* @param string $keyCache
* @param callable $value
* @param int $time 60
*/
$this->addMergeDataOtherKeyCache( string $key, string $keyCache, callable value, int $time 60 )