import "go.chromium.org/goma/server/cache"
Package cache provides cache service.
cache.go client.go doc.go local_client.go
type Cache struct {
// contains filtered or unexported fields
}
Cache represents key-value cache.
New creates new Cache for Config.
Get gets key-value for requested key. It returns codes.NotFound if value not found in cache.
Put puts new key-value pair in memcache (always; i.e. overwrite existing one) and cloud cache (if gcs is configured, and new value is put). It returns error if it fails to put cache in cloud storage.
type Client struct {
// contains filtered or unexported fields
}
Client is a client to access cache service via gRPC.
NewClient creates new client to access cache service serving on address. cache service will be sharded by key.
Close releases the resources used by the client.
func (c Client) Get(ctx context.Context, in *pb.GetReq, opts ...grpc.CallOption) (*pb.GetResp, error)
Get gets key-value data for requested key.
func (c Client) Put(ctx context.Context, in *pb.PutReq, opts ...grpc.CallOption) (*pb.PutResp, error)
Put puts new key-value data. If no key-value is given, do nothing.
type Config struct { // MaxBytes is maximum number of bytes used for cache. MaxBytes int64 Bucket *storage.BucketHandle }
Config is a configuration for Cache.
type LocalClient struct { pb.CacheServiceServer }
LocalClient is an adaptor to make CacheServiceServer as CacheServiceClient, ignoring any grpc.CallOption. TODO: use localhost server? https://github.com/grpc/grpc-go/issues/520
func (c LocalClient) Get(ctx context.Context, in *pb.GetReq, opts ...grpc.CallOption) (*pb.GetResp, error)
func (c LocalClient) Put(ctx context.Context, in *pb.PutReq, opts ...grpc.CallOption) (*pb.PutResp, error)
Path | Synopsis |
---|---|
gcs | Package gcs provides cache service by google cloud storage. |
redis | Package redis provides cache service by redis (cloud memorystore). |
Package cache imports 14 packages (graph) and is imported by 3 packages. Updated 2020-10-27. Refresh now. Tools for package owners.