ordent/cache-url-redis
Composer 安装命令:
composer require ordent/cache-url-redis
包简介
AIO Cache Management based on URL and Auth Implementation
README 文档
README
AIO cache management service based on URL and Auth JWT Implementation.
How To Use
- Install the package via composer
composer require ordent/cache-url-redis
- Implement the providers in your app configurations at
config/app.php
'providers' => [ Ordent\CacheURLRedis\Providers\URLCacheProvider::class ]
- Add a constant in the start of your
bootstart/app.phpto measure the execution time of your api.
define('EXEC_TIME_START', microtime(true));
- Add our middleware in
App\Http\Kernelto short circuit the computation process to redis when the URL key is found.
protected $middleware = [ Ordent\CacheURLRedis\Middleware\URLCacheMiddleware::class ]
- Don't forget to set up your
CACHEenv implementation.
CACHE_DRIVER=redis
Output
- We measure and deliver the endpoint execution time via response header
X-Elapsed-Time. - You need to send a Header in order to use the caching mechanism. If the header is not found on the request, the request will be computed normally. The header you need to set is
X-Cache-URLwith either value ofwith-authorwithout-auth. - When the value
without-authis being used, the application will short circuit the computation process to Redis with finding the key of request URL. - However if the value
with-authis used, the application will use the Redis with key format :{application-url}:{authorization-header-value}withauthorization-header-valueis your JWT token with Bearer format removed. - As of now the cache will last 60 minutes and won't cache another value unless you use header
X-Cache-URL-Invalidate, you can use it to invalidate the cache value after transaction or any other database change.
统计信息
- 总下载量: 2
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-08-22