|
| 1 | +# Driver support |
| 2 | + |
| 3 | +You may add integration with other http caches using the extension points provided by this bundle. |
| 4 | + |
| 5 | +The following extension points are available |
| 6 | + - PurgeClient |
| 7 | + - TagHandler |
| 8 | + - FOS TagHandler |
| 9 | + |
| 10 | +If you write a new PurgeClient driver, you **must** also create a corresponding TagHandler and vise |
| 11 | +versa. Creating a FOS TagHandler is optional. |
| 12 | + |
| 13 | + |
| 14 | +## PurgeClient |
| 15 | + |
| 16 | +The PurgeClient is responsible for sending purge requests to the http cache when content is about to be invalidated. |
| 17 | +The PurgeClient must implement EzSystems\PlatformHttpCacheBundle\PurgeClient\PurgeClientInterface and can be registered |
| 18 | +with the following code in service.yml: |
| 19 | + |
| 20 | +``` |
| 21 | +services: |
| 22 | + ezplatform.http_cache_myhttpcachebundle.purge_client.myhttpcache: |
| 23 | + class: EzSystems\PlatformMyHttpCacheBundle\PurgeClient\MyHttpCachePurgeClient |
| 24 | + arguments: ["@ezplatform.http_cache.cache_manager"] |
| 25 | + tags: |
| 26 | + - {name: ezplatform.http_cache.purge_client, purge_type: myhttpcache} |
| 27 | +``` |
| 28 | + |
| 29 | +Any service which implements the PurgeClientInterface must be tagged with `ezplatform.http_cache.purge_client` in order |
| 30 | +to be registered as such. |
| 31 | +`purge_type` specifies what the value of the purge_type setting in `app/config/ezplatform.yml` should be in order to |
| 32 | +enable this driver. |
| 33 | + |
| 34 | + |
| 35 | +## TagHandler |
| 36 | + |
| 37 | +The TagHandler is responsible for tagging responses with headers which the http cache recognizes. |
| 38 | +The TagHandler must implement EzSystems\PlatformHttpCacheBundle\Handler\TagHandlerInterface and can be registered with |
| 39 | +the following code in service.yml: |
| 40 | + |
| 41 | +``` |
| 42 | + ezplatform.http_cache_myhttpcachebundle.tag_handler.myhttpcache: |
| 43 | + class: EzSystems\PlatformMyHttpCacheBundle\Handler\MyHttpCacheTagHandler |
| 44 | + tags: |
| 45 | + - {name: ezplatform.http_cache.tag_handler, purge_type: myhttpcache} |
| 46 | +
|
| 47 | +``` |
| 48 | + |
| 49 | +Any service which implements the TagHandlerInterface must be tagged with `ezplatform.http_cache.tag_handler` in order |
| 50 | +to be registered as such. |
| 51 | + |
| 52 | +## FOS TagHandler |
| 53 | + |
| 54 | +The FOS Http cache bundle also have a TagHandler which is not used by eZ Platform except for one thing, the |
| 55 | +`fos:httpcache:invalidate:tag` command. With this command you may explicit invalidate cache by tag. |
| 56 | + |
| 57 | +Normally, you would not need to implement your own FOS TagHandler as the ezplatform-http-cache bundle ships with a |
| 58 | +default one which uses the PurgeClient to invalidate the given tags. |
| 59 | +If you anyway need to write your own FOS TagHandler, you may register it with the following code in service.yml: |
| 60 | + |
| 61 | +``` |
| 62 | + ezplatform.http_cache_myhttpcachebundle.fos_tag_handler.myhttpcache: |
| 63 | + class: EzSystems\PlatformMyHttpCacheBundle\Handler\MyHttpCacheFosTagHandler |
| 64 | + tags: |
| 65 | + - {name: ezplatform.http_cache.fos_tag_handler, purge_type: myhttpcache} |
| 66 | +``` |
0 commit comments