ordent / cache-url-redis
AIO Cache Management based on URL and Auth Implementation
Installs: 2
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
pkg:composer/ordent/cache-url-redis
Requires
- php: >=7.2
This package is auto-updated.
Last update: 2025-10-22 23:04:42 UTC
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.