Download the PHP package kleijnweb/rest-e-tag-bundle without Composer
On this page you can find all versions of the php package kleijnweb/rest-e-tag-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download kleijnweb/rest-e-tag-bundle
More information about kleijnweb/rest-e-tag-bundle
Files in kleijnweb/rest-e-tag-bundle
Package rest-e-tag-bundle
Short Description Caching and Concurrency Control for REST APIs using E-Tag Headers
License LGPL-3.0
Informations about the package rest-e-tag-bundle
KleijnWeb\RestETagBundle
Small bundle that adds caching and Concurrency Control for REST APIs using E-Tag Headers.
Go to the release page to find details about the latest release.
For an example see swagger-bundle-example.
NOTE: Looking for PHP <7.0 and Symfony <2.8.7 support? Use a 01.x version.
Functional Details
RestETagBundle uses REST semantics to form a cache invalidation and optimistic concurrency strategy.
- Versions the resources your URI paths represents and keeps this list in a server side cache.
- Increments the version of a path when one of the following methods is used: POST, PUT, PATCH, DELETE
- Increments the version of all parent and selected "lower" paths when that of a child is incremented
- Ensures the tag passed using If-Match matches the ETag in the cache, returns HTTP 412 in case of discrepancy.
- Returns HTTP 428 responses when concurrency control is enabled and the appropriate header is missing.
The bundle uses microtime based version IDs to prevent loss of the server side cache causing collisions and sub-second resource locking. Removes all non-printable and non-ascii chars from URLs before using them as cache keys.
The versioning scheme is pretty straightforward, examples:
-
Modifying
/animals/rabbits/1
: Invalidates/animals
,/animals/rabbits
,/animals/rabbits/1
, and (if it exists)/animals/rabbits/1/relations/owners
-
GET on
/animals/rabbits/2
: This is not effected by the previous example. In addition, this will create a version if none exists yet (without invalidating anything) - Modifying
/animals/rabbits
: Both/animals
and/animals/rabbits
get a new version. So will any existing versions matching the child invalidation constraint (see configuration), eg/animals/rabbits/findByName
The query part of the URL is treated as the last path segment:
-
Modifying
/animals?type=rabbits
: Will be interpreted as modification of/animals/?type=rabbits
. So/animals
will be invalidated. -
GET on
/animals?type=rabbits
: Will be interpreted as GET/animals/?type=rabbits
. -
Modifying
/animals/rabbits?id=1
: Will be interpreted as a modification of/animals/rabbits/?id=1
. So the old versions of both/animals
and/animals/rabbits
are invalidated too. - GET on
/animals?type=dogs
: Will be interpreted as GET/animals/?type=dogs
. So a modification of/animals?type=rabbits
will not affect it (but modification of/animals
will invalidate it).
The default child invalidation constraint is a negated regular expression: \/[0-9]+$
. This means a POST to /animals/rabbits
will by default not invalidate /animals/rabbits/1
or any paths below it, but will invalidate /animals/rabbits/findByName
.
NOTE: When concurrency control is turned on, you cannot POST to without the correct E-Tag either.
NOTE: The store and retrieve calls are not yet fully optimized and get pretty chatty when using network based caches. You can probably expect best performance from APCu. It won't use that much memory.
Install And Configure
Install using composer (composer require kleijnweb/rest-e-tag-bundle
). You want to check out the release page to ensure you are getting what you want and optionally verify your download.
Concurrency control is enabled by default. To disable:
The bundle will work with any PSR-16 cache (networked caches are strongly discouraged). Use the 'cache' config option to reference the service to be used:
You can tweak the default child invalidation constraint (negated, see default above):
License
KleijnWeb\RestETagBundle is made available under the terms of the LGPL, version 3.0.
All versions of rest-e-tag-bundle with dependencies
psr/log Version 1.0
symfony/dependency-injection Version >=2.6.0
symfony/config Version >=2.6.0
symfony/event-dispatcher Version >=2.6.0
symfony/http-foundation Version >=2.6.0
symfony/http-kernel Version >=2.6.0
symfony/yaml Version >=2.6.0
symfony/filesystem Version >=2.6.0
doctrine/cache Version ^1.5.4