Documentation
¶
Index ¶
- type Cache
- type CacheWithRenew
- func (c *CacheWithRenew[Key, Value]) Clear()
- func (c *CacheWithRenew[Key, Value]) Delete(key Key)
- func (c *CacheWithRenew[Key, Value]) Get(key Key) (value Value, ok bool)
- func (c *CacheWithRenew[Key, Value]) Set(key Key, value Value, lifecycle time.Duration, fn func() (Value, error))
- func (c *CacheWithRenew[Key, Value]) Swap(key Key, value Value) (previous Value, loaded bool)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
Cache is cache struct.
func (*Cache[Key, Value]) Clear ¶
func (c *Cache[Key, Value]) Clear()
Clear deletes all values in cache.
func (*Cache[Key, Value]) Delete ¶
func (c *Cache[Key, Value]) Delete(key *Key)
Delete deletes the value for a key.
type CacheWithRenew ¶ added in v0.1.75
type CacheWithRenew[Key comparable, Value any] struct { // contains filtered or unexported fields }
CacheWithRenew is cache struct.
func NewWithRenew ¶ added in v0.1.75
func NewWithRenew[Key comparable, Value any](autoRenew bool) *CacheWithRenew[Key, Value]
NewWithRenew creates a new cache with auto clean or not.
func (*CacheWithRenew[Key, Value]) Clear ¶ added in v0.1.75
func (c *CacheWithRenew[Key, Value]) Clear()
Clear deletes all values in cache.
func (*CacheWithRenew[Key, Value]) Delete ¶ added in v0.1.75
func (c *CacheWithRenew[Key, Value]) Delete(key Key)
Delete deletes the value for a key.
func (*CacheWithRenew[Key, Value]) Get ¶ added in v0.1.75
func (c *CacheWithRenew[Key, Value]) Get(key Key) (value Value, ok bool)
Get gets cache value by key and whether value was found.
func (*CacheWithRenew[Key, Value]) Set ¶ added in v0.1.75
func (c *CacheWithRenew[Key, Value]) Set(key Key, value Value, lifecycle time.Duration, fn func() (Value, error))
Set sets cache value for a key, if fn is presented, this value will regenerate when expired.
func (*CacheWithRenew[Key, Value]) Swap ¶ added in v0.1.75
func (c *CacheWithRenew[Key, Value]) Swap(key Key, value Value) (previous Value, loaded bool)
Swap swaps the value for a key and returns the previous value if any. The loaded result reports whether the key was present.
Click to show internal directories.
Click to hide internal directories.