QueryArgsCacheContext
class QueryArgsCacheContext extends RequestStackCacheContextBase implements CalculatedCacheContextInterface (View source)
Defines the QueryArgsCacheContext service, for "per query args" caching.
Cache context ID: 'url.query_args' (to vary by all query arguments). Calculated cache context ID: 'url.query_args:%key', e.g.'url.query_args:foo' (to vary by the 'foo' query argument).
Properties
| protected RequestStack | $requestStack | The request stack. |
from RequestStackCacheContextBase |
Methods
Constructs a new RequestStackCacheContextBase class.
Returns the label of the cache context.
Returns the string representation of the cache context.
Gets the cacheability metadata for the context based on the parameter value.
Details
__construct(RequestStack $request_stack)
Constructs a new RequestStackCacheContextBase class.
static string
getLabel()
Returns the label of the cache context.
string
getContext($query_arg = NULL)
Returns the string representation of the cache context.
A cache context service's name is used as a token (placeholder) cache key, and is then replaced with the string returned by this method.
CacheableMetadata
getCacheableMetadata($query_arg = NULL)
Gets the cacheability metadata for the context based on the parameter value.
There are three valid cases for the returned CacheableMetadata object:
- An empty object means this can be optimized away safely.
- A max-age of 0 means that this context can never be optimized away. It will never bubble up and cache tags will not be used.
- Any non-zero max-age and cache tags will bubble up into the cache item if this is optimized away to allow for invalidation if the context value changes.