Movatterモバイル変換


[0]ホーム

URL:


cache

package
v1.5.1Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 20, 2023 License:MITImports:12Imported by:0

Details

Repository

github.com/staticbackendhq/core

Links

Documentation

Overview

Package cache handles caching and pub/sub.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

typeCache

type Cache struct {Rdb *redis.ClientCtxcontext.Context// contains filtered or unexported fields}

Cache uses Redis to implement the Volatilizer interface

funcNewCache

func NewCache(log *logger.Logger) *Cache

NewCache returns an initiated Redis client

func (*Cache)Dec

func (c *Cache) Dec(keystring, byint64) (int64,error)

Dec decreases a value (atomic per Redis)

func (*Cache)DequeueWork

func (c *Cache) DequeueWork(keystring) (string,error)

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)Get

func (c *Cache) Get(keystring) (string,error)

Get gets a value by its id

func (*Cache)GetTyped

func (c *Cache) GetTyped(keystring, v interface{})error

GetTyped retrives the value for a key and unmarshal the JSON value into theinterface

func (*Cache)HasPermission

func (c *Cache) HasPermission(token, repo, payloadstring)bool

HasPermission determines if a session token has permission to a collection

func (*Cache)Inc

func (c *Cache) Inc(keystring, byint64) (int64,error)

Inc increments a value (atomic inc per Redis)

func (*Cache)Publish

func (c *Cache) Publish(msgmodel.Command)error

Publish sends a message and all subscribers will receive it if they'resubscribed to that topic

func (*Cache)PublishDocument

func (c *Cache) PublishDocument(authmodel.Auth, dbName, channel, typstring, v interface{})

PublishDocument publishes a database update message (created, updated, deleted)All subscribers will get notified

func (*Cache)QueueWork

func (c *Cache) QueueWork(key, valuestring)error

QueueWork uses Redis's LIST (atomic) as a work queue

func (*Cache)Set

func (c *Cache) Set(keystring, valuestring)error

Set sets a value for a key

func (*Cache)SetTyped

func (c *Cache) SetTyped(keystring, v interface{})error

SetTyped converts the interface into JSON before storing its string value

func (*Cache)Subscribe

func (c *Cache) Subscribe(send chanmodel.Command, token, channelstring, close chanbool)

Subscribe subscribes to a topic to receive messages on system/user events

typeCacheDevadded inv1.4.0

type CacheDev struct {// contains filtered or unexported fields}

CacheDev used in local dev mode and is memory-based

funcNewDevCacheadded inv1.4.0

func NewDevCache(log *logger.Logger) *CacheDev

NewDevCache returns a memory-based Volatilizer

func (*CacheDev)Decadded inv1.4.0

func (d *CacheDev) Dec(keystring, byint64) (int64,error)

Dec decrements a value (non-atomic)

func (*CacheDev)DequeueWorkadded inv1.4.0

func (d *CacheDev) DequeueWork(keystring) (valstring, errerror)

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)Getadded inv1.4.0

func (d *CacheDev) Get(keystring) (valstring, errerror)

Get gets a value by its id

func (*CacheDev)GetTypedadded inv1.4.0

func (d *CacheDev) GetTyped(keystring, vany)error

GetTyped retrives the value for a key and unmarshal the JSON value into the

func (*CacheDev)HasPermissionadded inv1.4.0

func (d *CacheDev) HasPermission(token, repo, payloadstring)bool

HasPermission determines if a session token has permission to a collection

func (*CacheDev)Incadded inv1.4.0

func (d *CacheDev) Inc(keystring, byint64) (nint64, errerror)

Inc increments a value (non-atomic)

func (*CacheDev)Publishadded inv1.4.0

func (d *CacheDev) Publish(msgmodel.Command)error

Publish sends a message and all subscribers will receive it if they'resubscribed to that topic

func (*CacheDev)PublishDocumentadded inv1.4.0

func (d *CacheDev) PublishDocument(authmodel.Auth, dbName, channel, typstring, vany)

PublishDocument publishes a database update message (created, updated, deleted)All subscribers will get notified

func (*CacheDev)QueueWorkadded inv1.4.0

func (d *CacheDev) QueueWork(key, valuestring)error

QueueWork uses a slice to replicate a work queue (non-atomic)

func (*CacheDev)Setadded inv1.4.0

func (d *CacheDev) Set(keystring, valuestring)error

Set sets a value for a key

func (*CacheDev)SetTypedadded inv1.4.0

func (d *CacheDev) SetTyped(keystring, vany)error

SetTyped converts the interface into JSON before storing its string value

func (*CacheDev)Subscribeadded inv1.4.0

func (d *CacheDev) Subscribe(send chanmodel.Command, token, channelstring, close chanbool)

Subscribe subscribes to a topic to receive messages on system/user events

typePublishDocumentEventadded inv1.4.1

type PublishDocumentEvent func(authmodel.Auth, dbName, channel, typstring, v interface{})

PublishDocumentEvent used to publish database events

typeVolatilizeradded 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

Source Files

View all Source files

Directories

PathSynopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp