cache

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2019 License: BSD-3-Clause Imports: 16 Imported by: 19

README

go-cache

Go package for reading and writing Who's On First documents from a variety of sources.

This package replaces go-whosonfirst-cache which will be retired soon.

Install

You will need to have both Go (version Go 1.12 or higher) and the make programs installed on your computer. Assuming you do just type:

make tools

All of this package's dependencies are bundled with the code in the vendor directory.

Interfaces

type Cache interface {
     	Name() string
	Get(context.Context, string) (io.ReadCloser, error)
	Set(context.Context, string, io.ReadCloser) (io.ReadCloser, error)
	Unset(context.Context, string) error
	Hits() int64
	Misses() int64
	Evictions() int64
	Size() int64
	SizeWithContext(context.Context) int64
}

See also

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetString

func GetString(c Cache, k string) (string, error)

func IsCacheMiss

func IsCacheMiss(e error) bool

func IsCacheMissMulti

func IsCacheMissMulti(e error) bool

func NewReadCloser

func NewReadCloser(b []byte) io.ReadCloser

func NewReadCloserFromString

func NewReadCloserFromString(s string) io.ReadCloser

func SetString

func SetString(c Cache, k string, v string) (string, error)

Types

type Cache

type Cache interface {
	Name() string
	Get(context.Context, string) (io.ReadCloser, error)
	Set(context.Context, string, io.ReadCloser) (io.ReadCloser, error)
	Unset(context.Context, string) error
	Hits() int64
	Misses() int64
	Evictions() int64
	Size() int64
	SizeWithContext(context.Context) int64
}

func NewFSCache

func NewFSCache(root string) (Cache, error)

func NewGoCache

func NewGoCache(opts *GoCacheOptions) (Cache, error)

func NewMultiCache

func NewMultiCache(caches []Cache) (Cache, error)

func NewNullCache

func NewNullCache() (Cache, error)

type CacheMiss

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

func (CacheMiss) Error

func (m CacheMiss) Error() string

type CacheMissMulti

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

func (CacheMissMulti) Error

func (m CacheMissMulti) Error() string

type FSCache

type FSCache struct {
	Cache

	TTL            int64
	FilePerms      os.FileMode
	DirectoryPerms os.FileMode
	// contains filtered or unexported fields
}

func (*FSCache) Evictions

func (c *FSCache) Evictions() int64

func (*FSCache) Get

func (c *FSCache) Get(ctx context.Context, key string) (io.ReadCloser, error)

func (*FSCache) Hits

func (c *FSCache) Hits() int64

func (*FSCache) Misses

func (c *FSCache) Misses() int64

func (*FSCache) Name

func (c *FSCache) Name() string

func (*FSCache) Set

func (c *FSCache) Set(ctx context.Context, key string, fh io.ReadCloser) (io.ReadCloser, error)

func (*FSCache) Size

func (c *FSCache) Size() int64

func (*FSCache) SizeWithContext

func (c *FSCache) SizeWithContext(ctx context.Context) int64

func (*FSCache) Unset

func (c *FSCache) Unset(ctx context.Context, key string) error

type GoCache

type GoCache struct {
	Cache
	Options *GoCacheOptions
	// contains filtered or unexported fields
}

func (*GoCache) Evictions

func (c *GoCache) Evictions() int64

func (*GoCache) Get

func (c *GoCache) Get(ctx context.Context, key string) (io.ReadCloser, error)

func (*GoCache) Hits

func (c *GoCache) Hits() int64

func (*GoCache) Misses

func (c *GoCache) Misses() int64

func (*GoCache) Name

func (c *GoCache) Name() string

func (*GoCache) Set

func (c *GoCache) Set(ctx context.Context, key string, fh io.ReadCloser) (io.ReadCloser, error)

func (*GoCache) Size

func (c *GoCache) Size() int64

func (*GoCache) SizeWithContext

func (c *GoCache) SizeWithContext(ctx context.Context) int64

func (*GoCache) Unset

func (c *GoCache) Unset(ctx context.Context, key string) error

type GoCacheOptions

type GoCacheOptions struct {
	DefaultExpiration time.Duration
	CleanupInterval   time.Duration
}

func DefaultGoCacheOptions

func DefaultGoCacheOptions() (*GoCacheOptions, error)

func GoCacheOptionsFromArgs

func GoCacheOptionsFromArgs(args map[string]string) (*GoCacheOptions, error)

type MultiCache

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

func (*MultiCache) Evictions

func (mc *MultiCache) Evictions() int64

func (*MultiCache) Get

func (mc *MultiCache) Get(ctx context.Context, key string) (io.ReadCloser, error)

func (*MultiCache) Hits

func (mc *MultiCache) Hits() int64

func (*MultiCache) Misses

func (mc *MultiCache) Misses() int64

func (*MultiCache) Name

func (mc *MultiCache) Name() string

func (*MultiCache) Set

func (mc *MultiCache) Set(ctx context.Context, key string, fh io.ReadCloser) (io.ReadCloser, error)

func (*MultiCache) Size

func (mc *MultiCache) Size() int64

func (*MultiCache) SizeWithContext

func (mc *MultiCache) SizeWithContext(ctx context.Context) int64

func (*MultiCache) Unset

func (mc *MultiCache) Unset(ctx context.Context, key string) error

type NullCache

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

func (*NullCache) Evictions

func (c *NullCache) Evictions() int64

func (*NullCache) Get

func (c *NullCache) Get(ctx context.Context, key string) (io.ReadCloser, error)

func (*NullCache) Hits

func (c *NullCache) Hits() int64

func (*NullCache) Misses

func (c *NullCache) Misses() int64

func (*NullCache) Name

func (c *NullCache) Name() string

func (*NullCache) Set

func (c *NullCache) Set(ctx context.Context, key string, fh io.ReadCloser) (io.ReadCloser, error)

func (*NullCache) Size

func (c *NullCache) Size() int64

func (*NullCache) SizeWithContext

func (c *NullCache) SizeWithContext(ctx context.Context) int64

func (*NullCache) Unset

func (c *NullCache) Unset(ctx context.Context, key string) error

Directories

Path Synopsis
cmd
wof-cache command

Jump to

Keyboard shortcuts

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