Documentation
¶
Index ¶
- type Cache
- func (sl *Cache[T]) Add(entry T) error
- func (sl *Cache[T]) CreateAndAdd(generate func() (T, error)) (T, error)
- func (sl *Cache[T]) Delete(entry T) (present bool)
- func (sl *Cache[T]) DeleteByID(id string) (present bool)
- func (sl *Cache[T]) Get(entry T) (T, bool)
- func (sl *Cache[T]) GetByID(id string) (T, bool)
- func (sl *Cache[T]) List() []T
- func (sl *Cache[T]) MostRecentOrCreate(generate func() (T, error)) (T, error)
- func (sl *Cache[T]) Newest() (T, bool)
- func (sl *Cache[T]) Size() int
- type CacheIdentifier
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache[T CacheIdentifier] struct { // contains filtered or unexported fields }
Cache is a thread-safe cache of generic entries.
func NewCache ¶
func NewCache[T CacheIdentifier](capacity int) *Cache[T]
func (*Cache[T]) CreateAndAdd ¶
func (*Cache[T]) DeleteByID ¶
func (*Cache[T]) MostRecentOrCreate ¶
type CacheIdentifier ¶
type CacheIdentifier interface {
Identifier() string
}
Click to show internal directories.
Click to hide internal directories.