boltdbttlcache

package
v0.0.0-...-61f2a12 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2017 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	PluginConfig = &boltdbttlcacheConfig{
		done: make(chan struct{}),
	}
)

Config ...

Functions

This section is empty.

Types

type ByIndexEntryExpiry

type ByIndexEntryExpiry []IndexEntry

func (ByIndexEntryExpiry) Len

func (s ByIndexEntryExpiry) Len() int

func (ByIndexEntryExpiry) Less

func (s ByIndexEntryExpiry) Less(i, j int) bool

func (ByIndexEntryExpiry) Swap

func (s ByIndexEntryExpiry) Swap(i, j int)

type Cache

type Cache struct {
	Groups map[string]*Group
	// contains filtered or unexported fields
}

func Mount

func Mount(db *bolt.DB) *Cache

Mount returns a new Cache using the provided (and opened) bolt database.

func New

func New(config *Config) (*Cache, error)

func (*Cache) Close

func (c *Cache) Close()

func (*Cache) CreateGroupIfNotExists

func (c *Cache) CreateGroupIfNotExists(key string) (*Group, error)

CreateGroupIfNotExists gets a group by key. If the grouiop does not exist, it will be created.

func (*Cache) Delete

func (c *Cache) Delete(key string)

Delete removes the response with the given key from the cache.

func (*Cache) DeleteGroup

func (c *Cache) DeleteGroup(key string) error

func (*Cache) Get

func (c *Cache) Get(key string) (resp []byte, ok bool)

Get retrieves the response corresponding to the given key if present.

func (*Cache) Set

func (c *Cache) Set(key string, resp []byte)

Set stores a response to the cache at the given key.

type CacheEntry

type CacheEntry struct {
	Key       []byte
	Value     interface{}
	CreatedAt time.Time
	ExpiresAt time.Time
}

type Config

type Config struct {
	Debug            bool
	GroupsName       string
	GroupName        string
	BucketName       string
	StoragePath      string
	DefaultGroupName string
	CacheTTL         time.Duration
}

type Group

type Group struct {
	sync.Mutex
	Key []byte
	// contains filtered or unexported fields
}

func (*Group) Count

func (g *Group) Count() int

func (*Group) Delete

func (g *Group) Delete(key []byte) error

func (*Group) Get

func (g *Group) Get(key []byte) (*CacheEntry, error)

func (*Group) Put

func (g *Group) Put(key []byte, value interface{}, ttl time.Duration) error

Set stores a response to the cache at the given key.

type IndexEntry

type IndexEntry struct {
	Key       []byte
	ExpiresAt time.Time
}

Jump to

Keyboard shortcuts

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