Documentation
¶
Overview ¶
Package cache handles caching and pub/sub.
Index ¶
- type Cache
- func (c *Cache) Dec(key string, by int64) (int64, error)
- func (c *Cache) DequeueWork(key string) (string, error)
- func (c *Cache) Get(key string) (string, error)
- func (c *Cache) GetTyped(key string, v interface{}) error
- func (c *Cache) HasPermission(token, repo, payload string) bool
- func (c *Cache) Inc(key string, by int64) (int64, error)
- func (c *Cache) Publish(msg model.Command) error
- func (c *Cache) PublishDocument(auth model.Auth, dbName, channel, typ string, v interface{})
- func (c *Cache) QueueWork(key, value string) error
- func (c *Cache) Set(key string, value string) error
- func (c *Cache) SetTyped(key string, v interface{}) error
- func (c *Cache) Subscribe(send chan model.Command, token, channel string, close chan bool)
- type CacheDev
- func (d *CacheDev) Dec(key string, by int64) (int64, error)
- func (d *CacheDev) DequeueWork(key string) (val string, err error)
- func (d *CacheDev) Get(key string) (val string, err error)
- func (d *CacheDev) GetTyped(key string, v any) error
- func (d *CacheDev) HasPermission(token, repo, payload string) bool
- func (d *CacheDev) Inc(key string, by int64) (n int64, err error)
- func (d *CacheDev) Publish(msg model.Command) error
- func (d *CacheDev) PublishDocument(auth model.Auth, dbName, channel, typ string, v any)
- func (d *CacheDev) QueueWork(key, value string) error
- func (d *CacheDev) Set(key string, value string) error
- func (d *CacheDev) SetTyped(key string, v any) error
- func (d *CacheDev) Subscribe(send chan model.Command, token, channel string, close chan bool)
- type PublishDocumentEvent
- type Volatilizer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct { Rdb *redis.Client Ctx context.Context // contains filtered or unexported fields }
Cache uses Redis to implement the Volatilizer interface
func (*Cache) DequeueWork ¶
DequeueWork uses Redis's LIST (atomic) to get the next work queue value You'd typically call this from a time.Ticker for instance or in some kind of loop
func (*Cache) GetTyped ¶
GetTyped retrives the value for a key and unmarshal the JSON value into the interface
func (*Cache) HasPermission ¶
HasPermission determines if a session token has permission to a collection
func (*Cache) Publish ¶
Publish sends a message and all subscribers will receive it if they're subscribed to that topic
func (*Cache) PublishDocument ¶
PublishDocument publishes a database update message (created, updated, deleted) All subscribers will get notified
type CacheDev ¶ added in v1.4.0
type CacheDev struct {
// contains filtered or unexported fields
}
CacheDev used in local dev mode and is memory-based
func NewDevCache ¶ added in v1.4.0
NewDevCache returns a memory-based Volatilizer
func (*CacheDev) DequeueWork ¶ added in v1.4.0
DequeueWork uses a string slice to replicate a work queue (non-atomic) You'd typically call this from a time.Ticker for instance or in some kind of loop
func (*CacheDev) GetTyped ¶ added in v1.4.0
GetTyped retrives the value for a key and unmarshal the JSON value into the
func (*CacheDev) HasPermission ¶ added in v1.4.0
HasPermission determines if a session token has permission to a collection
func (*CacheDev) Publish ¶ added in v1.4.0
Publish sends a message and all subscribers will receive it if they're subscribed to that topic
func (*CacheDev) PublishDocument ¶ added in v1.4.0
PublishDocument publishes a database update message (created, updated, deleted) All subscribers will get notified
func (*CacheDev) QueueWork ¶ added in v1.4.0
QueueWork uses a slice to replicate a work queue (non-atomic)
type PublishDocumentEvent ¶ added in v1.4.1
PublishDocumentEvent used to publish database events
type Volatilizer ¶ added in v1.4.1
type Volatilizer interface { // Get returns a string value from a key Get(key string) (string, error) // Set sets a string value Set(key string, value string) error // GetTyped returns a typed struct by its key GetTyped(key string, v any) error // SetTyped sets a typed struct for a key SetTyped(key string, v any) error // Inc increments a numeric value for a key Inc(key string, by int64) (int64, error) // Dec decrements a value for a key Dec(key string, by int64) (int64, error) // Subscribe subscribes to a pub/sub channel Subscribe(send chan model.Command, token, channel string, close chan bool) // Publish publishes a message to a channel Publish(msg model.Command) error // PublishDocument publish a database message to a channel PublishDocument(auth model.Auth, dbname, channel, typ string, v any) // QueueWork add a work queue item QueueWork(key, value string) error // DequeueWork dequeue work item (if available) DequeueWork(key string) (string, error) }
Volatilizer is the cache and pub/sub interface