Lustra::Model::QueryCache
The Lustra::Model::QueryCache is a fire-and-forget cache used when caching associations and preventing N+1 queries anti-pattern.
This is not a global cache: One cache instance exists per collection, and the cache disappear at the same time the Collection is unreferenced.
Each cache can references multiples relations at the same time. This cache use an underlying hash to access to the references keys.
Instance methods
Tell this cache than we active the cache over a specific relation name.
Returns self
Check whether the cache is active on a certain association.
Returns true if relation_name is flagged as encached, or false otherwise.
Try to hit the cache. If an array is found, it will be returned. Otherwise, empty array is returned.
This methods do not check if a relation flagged as is actively cached or not. Therefore, hitting a non-cached relation will return always an empty-array.
Set the cached array for a specific key {relation_name,relation_value}