Type | Description |
---|---|
UnconstrainedCache | Simple in-memory cache with no limits |
SlidingCache | In-memory cache that maintains a maximum number of entries |
FileCache | Persistent cache that stores data on disk |
NullCache | Special implementation that performs no caching (useful for testing) |
BaseCache
interface, making them interchangeable in your code.
Usage pattern | Description |
---|---|
Direct caching | Manually store and retrieve values |
Function decoration | Automatically cache function returns |
Tool integration | Cache tool execution results |
LLM integration | Cache model responses |
BaseCache
interface but performs no caching. Useful for testing or temporarily disabling caching.
The reason for implementing is to enable Null object pattern.
CacheFn
helper provides a functional approach:
BaseCache
class: