Documentation
¶
Overview ¶
Package cache provides caching mechanisms for API responses to improve performance and reduce external API calls.
Index ¶
- type Item
- type TTLCache
- func (c *TTLCache) Clear()
- func (c *TTLCache) Count() int
- func (c *TTLCache) Delete(key string)
- func (c *TTLCache) Get(key string) (interface{}, bool)
- func (c *TTLCache) Set(key string, value interface{})
- func (c *TTLCache) SetWithTTL(key string, value interface{}, ttl time.Duration)
- func (c *TTLCache) Stop()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Item ¶
type Item struct {
Value interface{}
Expiration int64
}
Item represents a cached item with expiration
type TTLCache ¶
type TTLCache struct {
// contains filtered or unexported fields
}
TTLCache is a thread-safe cache with time-based expiration
func GetGlobalCache ¶
func GetGlobalCache() *TTLCache
GetGlobalCache returns the global cache instance
func NewTTLCache ¶
NewTTLCache creates a new cache with the specified TTL and cleanup interval maxItems specifies the maximum number of items before oldest are evicted
func (*TTLCache) Get ¶
Get retrieves an item from the cache Returns the item and a bool indicating if the item was found
func (*TTLCache) SetWithTTL ¶
SetWithTTL adds an item to the cache with a specific TTL
Click to show internal directories.
Click to hide internal directories.