Documentation
¶
Overview ¶
Package cache provides a portable cache API with cross-cutting concerns.
Index ¶
- type Cache
- func (c *Cache) CreateCache(ctx context.Context, config driver.CacheConfig) (*driver.CacheInfo, error)
- func (c *Cache) Decr(ctx context.Context, cacheName, key string) (int64, error)
- func (c *Cache) DecrBy(ctx context.Context, cacheName, key string, delta int64) (int64, error)
- func (c *Cache) Delete(ctx context.Context, cacheName, key string) error
- func (c *Cache) DeleteCache(ctx context.Context, name string) error
- func (c *Cache) Expire(ctx context.Context, cacheName, key string, ttl time.Duration) error
- func (c *Cache) FlushAll(ctx context.Context, cacheName string) error
- func (c *Cache) Get(ctx context.Context, cacheName, key string) (*driver.Item, error)
- func (c *Cache) GetCache(ctx context.Context, name string) (*driver.CacheInfo, error)
- func (c *Cache) GetTTL(ctx context.Context, cacheName, key string) (time.Duration, error)
- func (c *Cache) Incr(ctx context.Context, cacheName, key string) (int64, error)
- func (c *Cache) IncrBy(ctx context.Context, cacheName, key string, delta int64) (int64, error)
- func (c *Cache) Keys(ctx context.Context, cacheName, pattern string) ([]string, error)
- func (c *Cache) ListCaches(ctx context.Context) ([]driver.CacheInfo, error)
- func (c *Cache) Persist(ctx context.Context, cacheName, key string) error
- func (c *Cache) Set(ctx context.Context, cacheName, key string, value []byte, ttl time.Duration) error
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache is the portable cache type wrapping a driver with cross-cutting concerns.
func (*Cache) CreateCache ¶
func (c *Cache) CreateCache(ctx context.Context, config driver.CacheConfig) (*driver.CacheInfo, error)
CreateCache creates a new cache instance.
func (*Cache) DecrBy ¶ added in v1.3.1
DecrBy atomically decrements the integer value of a key by delta.
func (*Cache) DeleteCache ¶
DeleteCache deletes a cache instance.
func (*Cache) GetTTL ¶ added in v1.3.1
GetTTL returns the remaining TTL for a key. Returns -1 if the key has no TTL.
func (*Cache) IncrBy ¶ added in v1.3.1
IncrBy atomically increments the integer value of a key by delta.
func (*Cache) ListCaches ¶
ListCaches lists all cache instances.
type Option ¶
type Option func(*Cache)
Option configures a portable Cache.
func WithErrorInjection ¶
WithErrorInjection sets the error injector.
func WithMetrics ¶
WithMetrics sets the metrics collector.
func WithRateLimiter ¶
WithRateLimiter sets the rate limiter.