cache

package
Version: v0.0.0-...-04a8642 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2021 License: GPL-2.0 Imports: 5 Imported by: 1

Documentation

Overview

Package cache provides an interface to cache items. It should not be of any concern to the callee where this cache is, simply that the cache exists and will speed things up.

Eventual consistency of the cached items is promised, but nothing more.

Index

Constants

View Source
const (
	CacheDetail     int = 1
	CacheSummary    int = 2
	CacheTitle      int = 3
	CacheItem       int = 4
	CacheDomain     int = 5
	CacheSubdomain  int = 6
	CacheUser       int = 7
	CacheProfileIds int = 8
	CacheCounts     int = 9
	CacheOptions    int = 10
	CacheRootID     int = 11 // Used only by the site type
	CacheBreadcrumb int = 12
	CacheAttributes int = 13
)

Maintains a list of constants that determine the type of content held in a key. A single ID may have multiple bits of data, i.e.

key_1 = 'detail for ID 1'
key_2 = 'summary for ID 1'

This allows us to nuke item 1 from cache and to purge the detail and summary for the item at the same time

Variables

This section is empty.

Functions

func Delete

func Delete(key string)

Delete removes items matching the given key from the cache, if it is in the cache

func Get

func Get(key string, dst interface{}) (interface{}, bool)

Get gets the data for the given key, if the data is in the cache

func GetBool

func GetBool(key string) (bool, bool)

GetBool is a utility function to get a bool from cache

func GetInt64

func GetInt64(key string) (int64, bool)

GetInt64 is a utility function to get an int64 from cache

func GetInt64Slice

func GetInt64Slice(key string) ([]int64, bool)

GetInt64Slice is a utility function to get a slice of int64 from cache

func GetString

func GetString(key string) (string, bool)

GetString is a utility function to get a string from cache

func InitCache

func InitCache(host string, port int64)

InitCache creates the cache client and enables the cache functions within this package. It is the responsibility of whatever has the values for this function (usually main.go shortly after reading the config file) to call this.

func Set

func Set(key string, data interface{}, timeToLive int32)

Set puts the given interface into the cache

func SetBool

func SetBool(key string, data bool, timeToLive int32)

SetBool is a utility function to put a bool into cache

func SetInt64

func SetInt64(key string, data int64, timeToLive int32)

SetInt64 is a utility function to put an int64 into cache

func SetInt64Slice

func SetInt64Slice(key string, data []int64, timeToLive int32)

SetInt64Slice is a utility function to put a slice of int64 into cache

func SetString

func SetString(key string, data string, timeToLive int32)

SetString is a utility function to put a string into cache

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL