Skip to content

Instantly share code, notes, and snippets.

@dbu
Last active February 8, 2016 12:19
Show Gist options
  • Save dbu/5b162a6707d8922014c9 to your computer and use it in GitHub Desktop.
Save dbu/5b162a6707d8922014c9 to your computer and use it in GitHub Desktop.
channel neutral tag handling for FOSHttpCache
<?php
/**
* Handle tagging. Both request and response are passed,
* so that tags can either be added to the response, or
* recorded with the request information.
*/
interface TagHandler
{
/**
* Remove/Expire cache objects based on cache tags
*/
public function invalidateTags(array $tags);
/**
* Record tag information.
*
* Either on the response (e.g. tags header) or out of band, linked to the
* request.
*
* @return ResponseInterface
*/
public function tagPsr(RequestInterface $request, ResponseInterface $response, array $tags);
/**
* Record tag information.
*
* Either sending a plain header, or recording the tags out of band, linked to the URL.
*/
public function tagPlain($url, array $tags);
/**
* Same as tagPsr but for symfony. in bundle only.
*/
public function tagSymfony(Request, Response, array $tags);
}
// implementation detail, not part of the interface
/**
* Get the value for the HTTP tag header.
*/
public function getTagsHeaderValue(array $tags);
/**
* Get the HTTP header name that will hold cache tags.
*/
public function getTagsHeaderName();
@dbu
Copy link
Author

dbu commented Feb 8, 2016

the user should not have to care about the tag implementation, whether its in band or out of band. that is why i would always pass the Request and let the tag handler decide whether to store a map of tag to response id or request url or whatever, or to put the tags into the response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment