cache

package
v0.0.0-...-396f595 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package cache provides an interface to the local Redis cache.

Index

Constants

View Source
const (
	// Cache key for the last sent Twitch message.
	KeyLastSentTwitchMessage = "twitch_last_sent_message"
	// Cache key for the platform that bot restart was requested from.
	KeyRestartRequestedOnPlatform = "restart_requested_on_platform"
	// Cache key for the channel that bot restart was requested from.
	KeyRestartRequestedInChannel = "restart_requested_from_channel"
	// Cache key for the ID of the message that requested the bot restart.
	KeyRestartRequestedByMessageID = "restart_requested_by_message"
)

Variables

This section is empty.

Functions

func GlobalSlowmodeKey

func GlobalSlowmodeKey(platformName string) string

GlobalSlowmodeKey returns the global slowmode cache key for a platform.

Types

type Cache

type Cache interface {
	// StoreBool stores a bool value with no expiration.
	StoreBool(key string, value bool) error
	// StoreExpiringBool stores a bool value with an expiration.
	// If the key does not exist, false will be returned.
	StoreExpiringBool(key string, value bool, expiration time.Duration) error
	// FetchBool fetches a bool value.
	// If the key does not exist, false will be returned.
	FetchBool(key string) (bool, error)

	// StoreString stores a string value with no expiration.
	StoreString(key, value string) error
	// StoreExpiringString stores a string value with an expiration.
	// If the key does not exist, an empty string will be returned.
	StoreExpiringString(key, value string, expiration time.Duration) error
	// FetchString fetches a string value.
	// If the key does not exist, an empty string will be returned.
	FetchString(key string) (string, error)
}

A Cache stores and retrieves simple key-value data quickly.

type Redis

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

Redis implements Cache for a real Redis database.

func NewRedis

func NewRedis() Redis

NewRedis creates a new Redis-backed Cache.

func (*Redis) FetchBool

func (c *Redis) FetchBool(key string) (bool, error)

func (*Redis) FetchString

func (c *Redis) FetchString(key string) (string, error)

func (*Redis) StoreBool

func (c *Redis) StoreBool(key string, value bool) error

func (*Redis) StoreExpiringBool

func (c *Redis) StoreExpiringBool(key string, value bool, expiration time.Duration) error

func (*Redis) StoreExpiringString

func (c *Redis) StoreExpiringString(key, value string, expiration time.Duration) error

func (*Redis) StoreString

func (c *Redis) StoreString(key, value string) error

Directories

Path Synopsis
Package cachetest provides a fake cache for testing.
Package cachetest provides a fake cache for testing.

Jump to

Keyboard shortcuts

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