Documentation
¶
Index ¶
- Variables
- func DeleteIf[T any](c *Cacher, bucketName string, cond func(key string, value T) bool) error
- func GetAll[T any](c *Cacher, bucketName string) (map[string]T, error)
- func Range[T any](c *Cacher, bucketName string, f func(key string, value T) bool) error
- func ToPtr[T any](v T) *T
- type Bucket
- type CacheStore
- type Cacher
- func (c *Cacher) CleanBucket(bucketName string) error
- func (c *Cacher) Close() error
- func (c *Cacher) Delete(bucketName string, key string) error
- func (c *Cacher) EmptyBucket(bucketName string) error
- func (c *Cacher) Get(bucketName string, key string, out interface{}) (bool, error)
- func (c *Cacher) GetFrozen(bucketName string, key string, out interface{}) (bool, error)
- func (c *Cacher) GetTotalSize() (int64, error)
- func (c *Cacher) RemoveAllBy(filter func(filename string) bool) error
- func (c *Cacher) RemoveBucket(bucketName string) error
- func (c *Cacher) Set(bucketName string, ttl time.Duration, key string, value interface{}) error
- func (c *Cacher) SetFrozen(bucketName string, key string, value interface{}) error
Constants ¶
This section is empty.
Variables ¶
var Ext = ".cache"
Functions ¶
Types ¶
type Bucket ¶
type Bucket struct {
// contains filtered or unexported fields
}
Bucket represents a cache bucket with a name and TTL.
type CacheStore ¶
type CacheStore struct {
// contains filtered or unexported fields
}
CacheStore represents a single-process, file-based, key/value cache store.
type Cacher ¶
type Cacher struct {
// contains filtered or unexported fields
}
func NewCacherWithExt ¶ added in v0.1.1
func (*Cacher) CleanBucket ¶
func (*Cacher) EmptyBucket ¶
EmptyBucket empties the given bucket (removes all items).
func (*Cacher) Get ¶
Get retrieves the value for the given key from the given bucket. If the key does not exist or has expired, it returns false. This removes the item from the cache if it has expired.
func (*Cacher) GetFrozen ¶
GetFrozen retrieves the value for the given key from the given bucket without checking for expiration.
func (*Cacher) GetTotalSize ¶
GetTotalSize returns the total size of all files in the cache directory that match the given filter. The size is in bytes.
func (*Cacher) RemoveAllBy ¶
RemoveAllBy removes all files in the cache directory that match the given filter.
func (*Cacher) RemoveBucket ¶
RemoveBucket removes the given bucket.