cache

package
v0.0.0-...-29a3764 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2020 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DEFAULT ...
	DEFAULT = time.Duration(0)
	// FOREVER ...
	FOREVER = time.Duration(-1)
	// CacheMiddlewareKey ...
	CacheMiddlewareKey = "gincontrib.cache"
)

Variables

This section is empty.

Functions

func Cache

func Cache(store CStore, expire time.Duration) gin.HandlerFunc

Cache Middleware

Types

type CStore

type CStore interface {
	Get(key string, value interface{}) error
	Set(key string, value interface{}, expire time.Duration) error
	Add(key string, value interface{}, expire time.Duration) error
	Replace(key string, data interface{}, expire time.Duration) error
	Delete(key string) error
	Increment(key string, data uint64) (uint64, error)
	Decrement(key string, data uint64) (uint64, error)
	Flush() error
}

CStore ...

type DBStore

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

DBStore ...

func NewDBStore

func NewDBStore() *DBStore

NewDBStore Returns instance of BoltDB backed cache store

func (*DBStore) Add

func (c *DBStore) Add(key string, value interface{}, expires time.Duration) error

Add ...

func (*DBStore) Decrement

func (c *DBStore) Decrement(key string, delta uint64) (uint64, error)

Decrement ...

func (*DBStore) Delete

func (c *DBStore) Delete(key string) error

Delete ...

func (*DBStore) Flush

func (c *DBStore) Flush() error

Flush ...

func (*DBStore) Get

func (c *DBStore) Get(key string, value interface{}) (err error)

Get ...

func (*DBStore) Increment

func (c *DBStore) Increment(key string, delta uint64) (uint64, error)

Increment ...

func (DBStore) MarshalMsg

func (z DBStore) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (DBStore) Msgsize

func (z DBStore) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*DBStore) Replace

func (c *DBStore) Replace(key string, value interface{}, expires time.Duration) error

Replace ...

func (*DBStore) Set

func (c *DBStore) Set(key string, value interface{}, expires time.Duration) (err error)

Set ...

func (*DBStore) UnmarshalMsg

func (z *DBStore) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type DBStoreItem

type DBStoreItem struct {
	Key   string      `json:"key"`
	Value interface{} `json:"value"`
}

DBStoreItem ...

func (DBStoreItem) MarshalMsg

func (z DBStoreItem) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (DBStoreItem) Msgsize

func (z DBStoreItem) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*DBStoreItem) UnmarshalMsg

func (z *DBStoreItem) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type FileStore

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

FileStore ...

func NewFileStore

func NewFileStore(path string) *FileStore

NewFileStore ...

func (*FileStore) Add

func (c *FileStore) Add(key string, value interface{}, expires time.Duration) error

Add ...

func (*FileStore) Decrement

func (c *FileStore) Decrement(key string, delta uint64) (uint64, error)

Decrement ...

func (*FileStore) Delete

func (c *FileStore) Delete(key string) error

Delete ...

func (*FileStore) Flush

func (c *FileStore) Flush() error

Flush ...

func (*FileStore) Get

func (c *FileStore) Get(key string, value interface{}) error

Get ...

func (*FileStore) Increment

func (c *FileStore) Increment(key string, delta uint64) (uint64, error)

Increment ...

func (*FileStore) Replace

func (c *FileStore) Replace(key string, value interface{}, expires time.Duration) error

Replace ...

func (*FileStore) Set

func (c *FileStore) Set(key string, value interface{}, expires time.Duration) error

Set ...

type ResponseCache

type ResponseCache struct {
	Status int
	Header http.Header
	Data   []byte
}

ResponseCache ...

Jump to

Keyboard shortcuts

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