gRPC-cache: Index | Files

package server

import ""


Package Files

api.go cache_service.go error.go


var (
    // ErrNoKey for key not found
    ErrNoKey = errors.New("No key found")
    // ErrKeyExpired for keys expired
    ErrKeyExpired = errors.New("Key expired")

type Cache Uses

type Cache struct {
    // contains filtered or unexported fields

Cache is a struct in which the cache's methods synchronize access to this map, so it is not recommended to keep any references to the map around after creating a cache.

func NewCacheService Uses

func NewCacheService(defaultExpiration, cleanupInterval time.Duration) *Cache

NewCacheService is used to initialize a new cache. Return a new cache with a given default expiration duration and cleanup interval. If the expiration duration is less than one, the items in the cache never expire (by default), and must be deleted manually. If the cleanup interval is less than one, expired items are not deleted from the cache before calling c.deleteExpired().

func (Cache) Add Uses

func (c Cache) Add(ctx context.Context, item *api.Item) (*api.Item, error)

Add is used to add key/value pair to the cache.

func (Cache) DeleteAll Uses

func (c Cache) DeleteAll(ctx context.Context, in *empty.Empty) (*api.Success, error)

Delete all items from the cache.

func (Cache) DeleteKey Uses

func (c Cache) DeleteKey(ctx context.Context, args *api.GetKey) (*api.Success, error)

DeleteKey deletes an item from the cache. Does nothing if the key is not in the cache.

func (Cache) Get Uses

func (c Cache) Get(ctx context.Context, args *api.GetKey) (*api.Item, error)

Get method is used to key/value pair while providing key as args

func (Cache) GetAllItems Uses

func (c Cache) GetAllItems(ctx context.Context, in *empty.Empty) (*api.AllItems, error)

GetAllItems method get all unexpired keys from the cache

func (Cache) GetByPrefix Uses

func (c Cache) GetByPrefix(ctx context.Context, args *api.GetKey) (*api.AllItems, error)

GetByPrefix method is all keys that match the prefix while providing key as args

type Item Uses

type Item struct {
    Object     interface{}
    Expiration int64

Item items value of key and expiration

Package server imports 8 packages (graph). Updated 2020-05-29. Refresh now. Tools for package owners.