Download the PHP package doekenorg/cache-middleware without Composer
On this page you can find all versions of the php package doekenorg/cache-middleware. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download doekenorg/cache-middleware
More information about doekenorg/cache-middleware
Files in doekenorg/cache-middleware
Package cache-middleware
Short Description An experimental middleware decorator for a PSR-6 cache pool
License MIT
Informations about the package cache-middleware
PSR-6 Cache Middleware
This is an experimental package that provides middleware for any PSR-6 cache pool.
Usage
To apply middlewares you decorate your PSR-6 cache pool with the DoekeNorg\CacheMiddleware\MiddlewareDecorator
. The
constructor of the decorator receives the decorated cache pool, as well as an optional list of middleware classes. You
can also add more middlewares by calling the addMiddleware(...$middlewares)
method on the decorator.
Types of middleware
This package provides three middleware interfaces:
MiddlewareGetInterface
: This middleware is called in combination with->getItem()
and->getItems()
MiddlewareSaveInterface
: This middleware is called in combination with->save()
and->safeDefered()
MiddlewareDeleteInterface
: This middleware is called in combination with->deleteItem()
and->deleteItems()
Implementing the interfaces
Every interface has a single process<Type>
method that gets called in the middleware process. So a single middleware
class can implement multiple middleware interfaces, and provide a common goal.
Notes
This package is a fun experiment to see if the middleware pattern can be useful around a PSR-6 cache. The package is
under development, and the implementation can change during the non-stable phase. As long as this is a 0.*.*
release
consider every minor change as a major update.
Warning: While it is possible to change the cache keys of the methods I do not recommend this in the middleware. Use it to update the cache item (adding tags, deleting other items for a given key, etc.).
Caveat: To trigger the middlewares on all items in combination with getItems()
and deleteItems()
these functions
do NOT call these functions on the decorated cache pool, but rather call getItem()
and deleteItem()
multiple times
on the decorator. This technically makes this decorator a proxy, but practically it still is a decorator. Just note that
if you need the inner methods called, this package probably isn't for you, and you should use a custom decorator.
Changelog
Please see the CHANGELOG for more information on what has changed recently.
License
The MIT License (MIT). Please see License File for more information.