cache

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2019 License: BSD-3-Clause Imports: 15 Imported by: 11

README

go-whosonfirst-cache

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

Install

You will need to have both Go (specifically version 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(string) (io.ReadCloser, error)
	Set(string, io.ReadCloser) (io.ReadCloser, error)
	Unset(string) error
	Hits() int64
	Misses() int64
	Evictions() int64
	Size() 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(string) (io.ReadCloser, error)
	Set(string, io.ReadCloser) (io.ReadCloser, error)
	Unset(string) error
	Hits() int64
	Misses() int64
	Evictions() int64
	Size() 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(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(key string, fh io.ReadCloser) (io.ReadCloser, error)

func (*FSCache) Size

func (c *FSCache) Size() int64

func (*FSCache) Unset

func (c *FSCache) Unset(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(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(key string, fh io.ReadCloser) (io.ReadCloser, error)

func (*GoCache) Size

func (c *GoCache) Size() int64

func (*GoCache) Unset

func (c *GoCache) Unset(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(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(key string, fh io.ReadCloser) (io.ReadCloser, error)

func (*MultiCache) Size

func (mc *MultiCache) Size() int64

func (*MultiCache) Unset

func (mc *MultiCache) Unset(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(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(key string, fh io.ReadCloser) (io.ReadCloser, error)

func (*NullCache) Size

func (c *NullCache) Size() int64

func (*NullCache) Unset

func (c *NullCache) Unset(key string) error

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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