Documentation ¶
Overview ¶
Package cache includes a memory cache for ntfy-alertmanager.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache interface { Set(fingerprint string, status string) error Contains(fingerprint string, status string) (bool, error) Cleanup() }
Cache is the interface that describes a cache for ntfy-alertmanager.
func NewCache ¶
func NewCache(cfg config.CacheConfig) (Cache, error)
NewCache reads the cache configuration cfg and creates the cache.
func NewDisabledCache ¶
NewDisabledCache creates a new disabled cache.
func NewMemoryCache ¶
NewMemoryCache creates a in-memory cache.
type DisabledCache ¶
type DisabledCache struct{}
DisabledCache is the disabled cache.
func (*DisabledCache) Cleanup ¶
func (c *DisabledCache) Cleanup()
Cleanup is an empty function to implement the interface.
func (*DisabledCache) Contains ¶
func (c *DisabledCache) Contains(_ string, _ string) (bool, error)
Contains is an empty function to implement the interface.
func (*DisabledCache) Set ¶
func (c *DisabledCache) Set(_ string, _ string) error
Set is an empty function to implement the interface.
type MemoryCache ¶
type MemoryCache struct {
// contains filtered or unexported fields
}
MemoryCache is the in-memory cache.
func (*MemoryCache) Cleanup ¶
func (c *MemoryCache) Cleanup()
Cleanup iterates over all alerts in the cache and removes them, if they are expired.
func (*MemoryCache) Contains ¶
func (c *MemoryCache) Contains(fingerprint string, status string) (bool, error)
Contains checks if an alert with a given fingerprint is in the cache and if the status matches.
func (*MemoryCache) Set ¶
func (c *MemoryCache) Set(fingerprint string, status string) error
Set saves an alert in the cache.
type RedisCache ¶
type RedisCache struct {
// contains filtered or unexported fields
}
RedisCache is the redis cache.
func (*RedisCache) Cleanup ¶
func (c *RedisCache) Cleanup()
Cleanup is an empty function that is simply here to implement the interface. Redis does its own cleanup.
func (*RedisCache) Contains ¶
func (c *RedisCache) Contains(fingerprint string, status string) (bool, error)
Contains checks if an alert with a given fingerprint is in the cache and if the status matches.
func (*RedisCache) Set ¶
func (c *RedisCache) Set(fingerprint string, status string) error
Set saves an alert in the cache.