Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrKeyIsEmpty is returned when the key is empty. ErrKeyIsEmpty = errors.New("key cannot be empty") // ErrValueIsNil is returned when the value is nil. ErrValueIsNil = errors.New("value cannot be nil") // ErrValueIsEmpty is returned when the value is empty. ErrValueIsEmpty = errors.New("value cannot be empty") // ErrInvalidTTL is returned when the TTL is less than or equal to 0. ErrInvalidTTL = errors.New("ttl must be greater than 0") // ErrKeyNotFound is returned when the key is not found in the cache. ErrKeyNotFound = errors.New("key not found") )
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache interface { Set(Key, Value) error Get(Key) (Value, error) Delete(Key) error Contains(Key) (bool, error) }
Cache is an interface that describes the behavior of a cache.
type InMemoryCache ¶
type InMemoryCache struct {
// contains filtered or unexported fields
}
InMemoryCache is a struct that represents a key-value In-Memory Cache.
func NewInMemoryCache ¶
func NewInMemoryCache() *InMemoryCache
NewInMemoryCache creates a new InMemoryCache.
func (*InMemoryCache) Contains ¶
func (c *InMemoryCache) Contains(key Key) (bool, error)
Contains checks if a value with the specified key exists in the cache.
func (*InMemoryCache) Delete ¶
func (c *InMemoryCache) Delete(key Key) error
Delete removes the element with the specified key from the cache.
Click to show internal directories.
Click to hide internal directories.