Documentation
¶
Index ¶
- Constants
- func NewFile(dir string) (standards.Cache, error)
- func NewRedis(client *redisLib.Client) standards.Cache
- type File
- func (c *File) Clear() error
- func (c *File) Commit() error
- func (c *File) DeleteItem(key string) error
- func (c *File) DeleteItems(keys ...string) error
- func (c *File) GetItem(key string) standards.CacheItem
- func (c *File) GetItems(keys ...string) []standards.CacheItem
- func (c *File) HasItem(key string) bool
- func (c *File) Save(item standards.CacheItem) error
- func (c *File) SaveDeferred(item standards.CacheItem) error
- type FileItem
- func (i *FileItem) ExpiresAfter(t time.Duration)
- func (i *FileItem) ExpiresAt(expiration time.Time) (standards.CacheItem, error)
- func (i *FileItem) Get() any
- func (i *FileItem) GetKey() string
- func (i *FileItem) IsHit() bool
- func (i *FileItem) Set(value any, ttl time.Duration) (standards.CacheItem, error)
- type FileSimple
- func (c *FileSimple) Clear() error
- func (c *FileSimple) Delete(key string) error
- func (c *FileSimple) DeleteMultiply(keys ...string) error
- func (c *FileSimple) Get(key string, defaultValue any) any
- func (c *FileSimple) GetMultiply(keys []string, defaultValue any) []any
- func (c *FileSimple) Has(key string) bool
- func (c *FileSimple) Set(key string, item any, ttl time.Duration) error
- func (c *FileSimple) SetMultiply(values map[string]any, ttl time.Duration) error
- type Memory
- func (c *Memory) Clear() error
- func (c *Memory) Commit() error
- func (c *Memory) DeleteItem(key string) error
- func (c *Memory) DeleteItems(keys ...string) error
- func (c *Memory) GetItem(key string) standards.CacheItem
- func (c *Memory) GetItems(keys ...string) []standards.CacheItem
- func (c *Memory) HasItem(key string) bool
- func (c *Memory) Save(item standards.CacheItem) error
- func (c *Memory) SaveDeferred(item standards.CacheItem) error
- type MemoryItem
- func (m *MemoryItem) ExpiresAfter(t time.Duration)
- func (m *MemoryItem) ExpiresAt(expiration time.Time) (standards.CacheItem, error)
- func (m *MemoryItem) Get() any
- func (m *MemoryItem) GetKey() string
- func (m *MemoryItem) IsHit() bool
- func (m *MemoryItem) Set(value any, ttl time.Duration) (standards.CacheItem, error)
- type Redis
- func (c *Redis) Clear() error
- func (c *Redis) Commit() error
- func (c *Redis) DeleteItem(key string) error
- func (c *Redis) DeleteItems(keys ...string) error
- func (c *Redis) GetItem(key string) standards.CacheItem
- func (c *Redis) GetItems(keys ...string) []standards.CacheItem
- func (c *Redis) HasItem(key string) bool
- func (c *Redis) Save(item standards.CacheItem) error
- func (c *Redis) SaveDeferred(item standards.CacheItem) error
- type RedisItem
- func (r *RedisItem) ExpiresAfter(t time.Duration)
- func (r *RedisItem) ExpiresAt(expiration time.Time) (standards.CacheItem, error)
- func (r *RedisItem) Get() any
- func (r *RedisItem) GetKey() string
- func (r *RedisItem) IsHit() bool
- func (r *RedisItem) Set(value any, ttl time.Duration) (standards.CacheItem, error)
- type Storage
- func (s *Storage) Add(name string, cache standards.Cache) (standards.Cache, error)
- func (s *Storage) AddFile(name, dir string) (standards.Cache, error)
- func (s *Storage) AddMemory(name string) (standards.Cache, error)
- func (s *Storage) AddRedis(name string, client *redisLib.Client) (standards.Cache, error)
- func (s *Storage) Get(name string) (cache standards.Cache, exists bool)
Constants ¶
View Source
const FILE_EXTENSION = ".cache"
View Source
const KeepTTL = standards.KeepTTL
Variables ¶
This section is empty.
Functions ¶
Types ¶
type FileItem ¶
type FileItem struct { Key string `json:"key"` Value any `json:"value"` Expiration time.Time `json:"expiration"` KeepTTL bool }
func NewFileItem ¶
func (*FileItem) ExpiresAfter ¶
type FileSimple ¶ added in v1.0.2
func NewFileSimple ¶ added in v1.0.2
func NewFileSimple(dir string) (*FileSimple, error)
NewFileSimple create FileSimple instance with not allowed default value nil
func NewFileSimpleWithDefaultNil ¶ added in v1.0.2
func NewFileSimpleWithDefaultNil(dir string, allowDefaultNil bool) (*FileSimple, error)
NewFileSimpleWithDefaultNil create FileSimple instance
func (*FileSimple) Clear ¶ added in v1.0.2
func (c *FileSimple) Clear() error
Clear Deletes all cache's keys.
func (*FileSimple) Delete ¶ added in v1.0.2
func (c *FileSimple) Delete(key string) error
Delete Remove an item from the cache.
func (*FileSimple) DeleteMultiply ¶ added in v1.0.2
func (c *FileSimple) DeleteMultiply(keys ...string) error
DeleteMultiply Removes multiple items in a single operation.
func (*FileSimple) Get ¶ added in v1.0.2
func (c *FileSimple) Get(key string, defaultValue any) any
Get Returns a value from the cache.
func (*FileSimple) GetMultiply ¶ added in v1.0.2
func (c *FileSimple) GetMultiply(keys []string, defaultValue any) []any
GetMultiply Returns a list of cache items.
func (*FileSimple) Has ¶ added in v1.0.2
func (c *FileSimple) Has(key string) bool
Has Determines whether an item is present in the cache.
func (*FileSimple) SetMultiply ¶ added in v1.0.2
SetMultiply Persists a cache items.
type Memory ¶
type Memory struct {
// contains filtered or unexported fields
}
func (*Memory) DeleteItem ¶
func (*Memory) DeleteItems ¶
type MemoryItem ¶
type MemoryItem struct { KeepTTL bool // contains filtered or unexported fields }
func NewMemoryItem ¶
func NewMemoryItem(key string) *MemoryItem
func (*MemoryItem) ExpiresAfter ¶
func (m *MemoryItem) ExpiresAfter(t time.Duration)
func (*MemoryItem) Get ¶
func (m *MemoryItem) Get() any
func (*MemoryItem) GetKey ¶
func (m *MemoryItem) GetKey() string
func (*MemoryItem) IsHit ¶
func (m *MemoryItem) IsHit() bool
type Redis ¶
type Redis struct {
// contains filtered or unexported fields
}
func (*Redis) DeleteItem ¶
func (*Redis) DeleteItems ¶
type RedisItem ¶
type RedisItem struct { KeepTTL bool // contains filtered or unexported fields }
func NewRedisItem ¶
func (*RedisItem) ExpiresAfter ¶
type Storage ¶ added in v1.0.3
func GetStorage ¶ added in v1.0.6
func GetStorage() *Storage
GetStorage get storage (for global usages)
func NewStorage ¶ added in v1.0.3
func NewStorage() *Storage
NewStorage create new instance of Storage
func (*Storage) AddMemory ¶ added in v1.0.3
AddMemory create Memory cache instance and add it to list
Click to show internal directories.
Click to hide internal directories.