Apivalk features a generic, high-performance caching layer designed to optimize resource-intensive operations, such as automated route discovery and metadata processing.
To provide a “zero-config” experience, Apivalk performs automated discovery of controllers and their metadata. While this is extremely developer-friendly, scanning the filesystem and parsing classes on every request would be inefficient.The cache layer ensures that these operations are performed only when necessary, persisting the results for subsequent requests.
A CacheItem is a value object that encapsulates the cached data along with its metadata:
Key: A unique identifier for the item.
Value: The data being stored (serialized/deserialized automatically).
TTL: Time-to-live in seconds.
Created At: When the item was created (UTC DateTime object).
Make sure that you always use the CacheItem class to interact with the cache.
When you want a custom “createdAt”, you can pass it as a second argument to the constructor. If you do that, make sure to use UTC as a timezone in the given DateTime object because the createdAt focuses on ZULU Timestamp (serialization/deserialization is done automatically).