grpc: google.golang.org/grpc/internal/cache Index | Files

package cache

import "google.golang.org/grpc/internal/cache"

Package cache implements caches to be used in gRPC.

Index

Package Files

timeoutCache.go

type TimeoutCache Uses

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

TimeoutCache is a cache with items to be deleted after a timeout.

func NewTimeoutCache Uses

func NewTimeoutCache(timeout time.Duration) *TimeoutCache

NewTimeoutCache creates a TimeoutCache with the given timeout.

func (*TimeoutCache) Add Uses

func (c *TimeoutCache) Add(key, item interface{}, callback func()) (interface{}, bool)

Add adds an item to the cache, with the specified callback to be called when the item is removed from the cache upon timeout. If the item is removed from the cache using a call to Remove before the timeout expires, the callback will not be called.

If the Add was successful, it returns (newly added item, true). If there is an existing entry for the specified key, the cache entry is not be updated with the specified item and it returns (existing item, false).

func (*TimeoutCache) Clear Uses

func (c *TimeoutCache) Clear(runCallback bool)

Clear removes all entries, and runs the callbacks if runCallback is true.

func (*TimeoutCache) Remove Uses

func (c *TimeoutCache) Remove(key interface{}) (item interface{}, ok bool)

Remove the item with the key from the cache.

If the specified key exists in the cache, it returns (item associated with key, true) and the callback associated with the item is guaranteed to be not called. If the given key is not found in the cache, it returns (nil, false)

Package cache imports 2 packages (graph) and is imported by 1 packages. Updated 2019-10-21. Refresh now. Tools for package owners.