redis

package
v0.0.0-...-c9ce307 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2022 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler interface {
	// Put adds a value with key to the cache which will expire after a specified ttl.
	Put(ctx context.Context, key string, v any, ttl time.Duration) error
	// Get fetches a value from the cache with given key.
	Get(ctx context.Context, key string) (any, error)
	// Delete deletes a value with given key from the cache.
	Delete(ctx context.Context, key string) error
	// ClearSession wipes the session from Redis. Removes all pages and the respective strokes on the pages
	ClearSession(ctx context.Context, sessionID string) error
	// UpdateStrokes adds board strokes in Redis.
	//
	// Creates a JSON encoding for each slice entry which
	// is stored to the database.
	// Delete the stroke with given id if stroke type is set to delete.
	UpdateStrokes(ctx context.Context, sessionId string, strokes ...Stroke) error
	// GetPageStrokes Fetches all strokes of the specified page.
	//
	// Preserves the JSON encoding of Redis and returns an array of
	// a stringified stroke objects.
	GetPageStrokes(ctx context.Context, sessionID, pageID string) ([][]byte, error)
	// GetPageRank returns a list of all pageIDs for the current session.
	//
	// The PageIDs are maintained in a list in redis since the ordering is important
	GetPageRank(ctx context.Context, sessionID string) ([]string, error)
	// GetPageMeta returns a slice of all page meta data.
	GetPageMeta(ctx context.Context, sessionId, pageId string, meta any) error
	// SetPageMeta sets the page meta data
	SetPageMeta(ctx context.Context, sessionId, pageId string, meta any) error
	// AddPage adds a page with pageID at position index.
	//
	// Other pages are moved and their score is reassigned
	// when pages are added in between
	AddPage(ctx context.Context, sessionID, newPageID string, index int, meta any) error
	// DeletePage deletes a page and the respective strokes on the page and remove the PageID from the list.
	DeletePage(ctx context.Context, sessionID, pageID string) error
	// ClearPage removes all strokes with given pageID.
	ClearPage(ctx context.Context, sessionID, pageID string) error
	ClosePool() error
}

func New

func New(host string, port uint16) (Handler, error)

New creates a new redis intance and initializes the Redis thread pool.

type Stroke

type Stroke interface {
	Id() string
	PageId() string
	IsDeleted() bool
}

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL