Documentation
¶
Index ¶
- type Cache
- func (c *Cache) Clear()
- func (c *Cache) DeleteItem(key string)
- func (c *Cache) GetAllItems() []*CacheItem
- func (c *Cache) GetItem(key string) (*CacheItem, bool)
- func (c *Cache) GetItems(pageNum int, pageSize int) []*CacheItem
- func (c *Cache) GetMaxSize() int
- func (c *Cache) GetTotalItems() int
- func (c *Cache) SetItem(key string, value interface{})
- type CacheItem
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache defines the structure of the cache, including a map for quick lookup, a doubly linked list to maintain order, a mutex for concurrent access, a size limit, and a tag for logging.
func NewCache ¶
NewCache initializes a new cache with the specified size and tag, and logs the initialization event.
func (*Cache) DeleteItem ¶
DeleteItem removes an item from the cache based on its key.
func (*Cache) GetAllItems ¶
GetAllItems returns a slice containing all items in the cache.
func (*Cache) GetItem ¶
GetItem retrieves an item from the cache based on its key, marking the item as recently used if found.
func (*Cache) GetItems ¶
GetItems returns a slice of CacheItems from the cache, based on the specified pagination parameters.
func (*Cache) GetMaxSize ¶
GetMaxSize returns the maximum size of the cache.
func (*Cache) GetTotalItems ¶
GetTotalItems returns the total number of items currently in the cache.