cache

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

Cache keeps firestore client and collection

var Client Cache

func Connect

func Connect() (Cache, error)

Connect establishes connection to Firebase and update singleton variable

func (*Cache) GetKey

func (c *Cache) GetKey(key string, to interface{}) (string, error)

GetKey retrieve value by key from cache store

func (*Cache) MarshalAndSetKey

func (c *Cache) MarshalAndSetKey(key string, value interface{}, exp time.Duration) error

MarshalAndSetKey is the same as SetKey but before that it marshals value. Simple helper

func (*Cache) SetKey

func (c *Cache) SetKey(key, value string, exp time.Duration) error

SetKey saves value for key in cache store with expiration time

type Entity

type Entity struct {
	Key   string        `firestore:"key"`
	Value string        `firestore:"value"`
	Ttl   time.Duration `firestore:"ttl"`
}

Entity is a model for Firestore that handles cache with ttl

Jump to

Keyboard shortcuts

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