cache

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2020 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package cache implements Swx GRPC response cache

Index

Constants

View Source
const (
	// defaultTtl - cached entity TTL after last recent use
	DefaultTtl = time.Hour * 3
	// defaultGcInterval - frequency of Garbage Collection checks
	DefaultGcInterval = time.Minute * 5
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Impl

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

func New

func New() *Impl

New creates & returns a new instance of the cache

func NewExt

func NewExt(interval, ttl time.Duration) (*Impl, chan struct{})

NewExt creates & returns a new instance of the cache and GC cancellation chan

func (*Impl) ClearAll

func (swxCache *Impl) ClearAll()

ClearAll removes all cached entities & re-initializes the cache

func (*Impl) Gc

func (swxCache *Impl) Gc(interval, ttl time.Duration) chan struct{}

Gc starts Garbage Collector with specified check interval & TTL. Returns chan to stop the GC: done := cache.Gc(interval, ttl); ... done <- struct{}{}; ...

func (*Impl) Get

func (swxCache *Impl) Get(imsi string) *protos.AuthenticationAnswer

Get retrieves one auth vector from cache if available, adjusts cache and returns the vector, returns nil otherwise

func (*Impl) Put

Put adds ans vectors into the cache after extracting the first vector from the list, which it returns back to the caller in the returned AuthenticationAnswer

func (*Impl) Remove

func (swxCache *Impl) Remove(imsi string) *protos.AuthenticationAnswer

Remove removes all auth vectors for the IMSI from cache and returns the removed item if available

Jump to

Keyboard shortcuts

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