cachestore

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: May 8, 2024 License: Apache-2.0 Imports: 7 Imported by: 1

Documentation

Overview

Package cachestore implements the blob.Store that delegates to an underlying store through an in-memory cache.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CAS

type CAS struct {
	*Store
	// contains filtered or unexported fields
}

CAS implements a cached wrapper around a blob.CAS instance.

func NewCAS

func NewCAS(cas blob.CAS, maxBytes int) CAS

NewCAS constructs a new cached store with the specified capacity in bytes, delegating storage operations to cas. It will panic if maxBytes < 0.

func (CAS) CASKey

func (c CAS) CASKey(ctx context.Context, opts blob.CASPutOptions) (string, error)

CASKey implements part of blob.CAS using the underlying store.

func (CAS) CASPut

func (c CAS) CASPut(ctx context.Context, opts blob.CASPutOptions) (string, error)

CASPut implements part of blob.CAS using the underlying store.

type Store

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

Store implements a blob.Store that delegates to an underlying store through an in-memory cache. This is appropriate for a high-latency or quota-limited remote store (such as a GCS or S3 bucket) that will not be concurrently written by other processes; concurrent readers are fine.

Both reads and writes are cached, and the store writes through to the underlying store. Negative hits from Get and Size are also cached.

func New

func New(s blob.Store, maxBytes int) *Store

New constructs a new cached store with the specified capacity in bytes, delegating storage operations to s. It will panic if maxBytes < 0.

func (*Store) Close

func (s *Store) Close(ctx context.Context) error

Close implements blob.Closer by closing the underlying store.

func (*Store) Delete

func (s *Store) Delete(ctx context.Context, key string) error

Delete implements a method of blob.Store.

func (*Store) Get

func (s *Store) Get(ctx context.Context, key string) ([]byte, error)

Get implements a method of blob.Store.

func (*Store) Len

func (s *Store) Len(ctx context.Context) (int64, error)

Len implements a method of blob.Store.

func (*Store) List

func (s *Store) List(ctx context.Context, start string, f func(string) error) error

List implements a method of blob.Store.

func (*Store) Put

func (s *Store) Put(ctx context.Context, opts blob.PutOptions) error

Put implements a method of blob.Store.

Jump to

Keyboard shortcuts

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