e7bd392a69
This fixes an important bug with listing that affects users with more than 500 objects in a listing operation. |
||
---|---|---|
.. | ||
cache.go | ||
doc.go | ||
README.md |
package drpccache
import "storj.io/drpc/drpccache"
Package drpccache implements per stream cache for drpc.
Usage
func WithContext
func WithContext(parent context.Context, cache *Cache) context.Context
WithContext returns a context with the value cache associated with the context.
type Cache
type Cache struct {
}
Cache is a per stream cache.
func FromContext
func FromContext(ctx context.Context) *Cache
FromContext returns a cache from a context.
Example usage:
cache := drpccache.FromContext(stream.Context())
if cache != nil {
value := cache.LoadOrCreate("initialized", func() (interface{}) {
return 42
})
}
func New
func New() *Cache
New returns a new cache.
func (*Cache) Clear
func (cache *Cache) Clear()
Clear clears the cache.
func (*Cache) Load
func (cache *Cache) Load(key interface{}) interface{}
Load returns the value with the given key.
func (*Cache) LoadOrCreate
func (cache *Cache) LoadOrCreate(key interface{}, fn func() interface{}) interface{}
LoadOrCreate returns the value with the given key.
func (*Cache) Store
func (cache *Cache) Store(key, value interface{})
Store sets the value at a key.