server: go.chromium.org/goma/server/cache Index | Files | Directories

package cache

import "go.chromium.org/goma/server/cache"

Package cache provides cache service.

Index

Package Files

cache.go client.go doc.go local_client.go

type Cache Uses

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

Cache represents key-value cache.

func New Uses

func New(c Config) (*Cache, error)

New creates new Cache for Config.

func (*Cache) Get Uses

func (c *Cache) Get(ctx context.Context, req *cachepb.GetReq) (*cachepb.GetResp, error)

Get gets key-value for requested key. It returns codes.NotFound if value not found in cache.

func (*Cache) Put Uses

func (c *Cache) Put(ctx context.Context, req *cachepb.PutReq) (*cachepb.PutResp, error)

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 Uses

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

Client is a client to access cache service via gRPC.

func NewClient Uses

func NewClient(ctx context.Context, address string, opts ...grpc.DialOption) Client

NewClient creates new client to access cache service serving on address. cache service will be sharded by key.

func (Client) Close Uses

func (c Client) Close() error

Close releases the resources used by the client.

func (Client) Get Uses

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 (Client) Put Uses

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 Uses

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 Uses

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 (LocalClient) Get Uses

func (c LocalClient) Get(ctx context.Context, in *pb.GetReq, opts ...grpc.CallOption) (*pb.GetResp, error)

func (LocalClient) Put Uses

func (c LocalClient) Put(ctx context.Context, in *pb.PutReq, opts ...grpc.CallOption) (*pb.PutResp, error)

Directories

PathSynopsis
gcsPackage gcs provides cache service by google cloud storage.
redisPackage redis provides cache service by redis (cloud memorystore).

Package cache imports 14 packages (graph) and is imported by 3 packages. Updated 2019-07-13. Refresh now. Tools for package owners.