cache
packageThis package is not in the latest version of its module.
Details
Validgo.mod file
The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable license
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Tagged version
Modules with tagged versions give importers more predictable builds.
Stable version
When a project reaches major version v1 it is considered stable.
- Learn more about best practices
Repository
Links
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¶
typeCache¶
Cache uses Redis to implement the Volatilizer interface
func (*Cache)DequeueWork¶
DequeueWork uses Redis's LIST (atomic) to get the next work queue valueYou'd typically call this from a time.Ticker for instance or in somekind of loop
func (*Cache)GetTyped¶
GetTyped retrives the value for a key and unmarshal the JSON value into theinterface
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'resubscribed to that topic
func (*Cache)PublishDocument¶
PublishDocument publishes a database update message (created, updated, deleted)All subscribers will get notified
typeCacheDev¶added inv1.4.0
type CacheDev struct {// contains filtered or unexported fields}CacheDev used in local dev mode and is memory-based
funcNewDevCache¶added inv1.4.0
NewDevCache returns a memory-based Volatilizer
func (*CacheDev)DequeueWork¶added inv1.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 somekind of loop
func (*CacheDev)GetTyped¶added inv1.4.0
GetTyped retrives the value for a key and unmarshal the JSON value into the
func (*CacheDev)HasPermission¶added inv1.4.0
HasPermission determines if a session token has permission to a collection
func (*CacheDev)Publish¶added inv1.4.0
Publish sends a message and all subscribers will receive it if they'resubscribed to that topic
func (*CacheDev)PublishDocument¶added inv1.4.0
PublishDocument publishes a database update message (created, updated, deleted)All subscribers will get notified
func (*CacheDev)QueueWork¶added inv1.4.0
QueueWork uses a slice to replicate a work queue (non-atomic)
typePublishDocumentEvent¶added inv1.4.1
PublishDocumentEvent used to publish database events
typeVolatilizer¶added inv1.4.1
type Volatilizer interface {// Get returns a string value from a keyGet(keystring) (string,error)// Set sets a string valueSet(keystring, valuestring)error// GetTyped returns a typed struct by its keyGetTyped(keystring, vany)error// SetTyped sets a typed struct for a keySetTyped(keystring, vany)error// Inc increments a numeric value for a keyInc(keystring, byint64) (int64,error)// Dec decrements a value for a keyDec(keystring, byint64) (int64,error)// Subscribe subscribes to a pub/sub channelSubscribe(send chanmodel.Command, token, channelstring, close chanbool)// Publish publishes a message to a channelPublish(msgmodel.Command)error// PublishDocument publish a database message to a channelPublishDocument(authmodel.Auth, dbname, channel, typstring, vany)// QueueWork add a work queue itemQueueWork(key, valuestring)error// DequeueWork dequeue work item (if available)DequeueWork(keystring) (string,error)}Volatilizer is the cache and pub/sub interface