cache

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AsClient

func AsClient(client interface{}) *sql.DB

func New

func New() cache.Cache

New creates and returns a new postgres cacher.

Types

type PostgresCacher

type PostgresCacher struct {
	cache.GetAs
	// contains filtered or unexported fields
}

PostgresCacher represents a postgres cache adapter implementation.

func (*PostgresCacher) Client

func (c *PostgresCacher) Client() interface{}

func (*PostgresCacher) Close

func (c *PostgresCacher) Close() error

func (*PostgresCacher) Codec

func (c *PostgresCacher) Codec() encoding.Codec

func (*PostgresCacher) Decr

func (c *PostgresCacher) Decr(ctx context.Context, key string) error

Decr cached int value.

func (*PostgresCacher) Delete

func (c *PostgresCacher) Delete(ctx context.Context, key string) error

Delete deletes cached value by given key.

func (*PostgresCacher) Flush

func (c *PostgresCacher) Flush(ctx context.Context) error

Flush deletes all cached data.

func (*PostgresCacher) Get

func (c *PostgresCacher) Get(ctx context.Context, key string, value interface{}) error

Get gets cached value by given key.

func (*PostgresCacher) Incr

func (c *PostgresCacher) Incr(ctx context.Context, key string) error

Incr increases cached int-type value by given key as a counter.

func (*PostgresCacher) IsExist

func (c *PostgresCacher) IsExist(ctx context.Context, key string) (bool, error)

IsExist returns true if cached value exists.

func (*PostgresCacher) Name added in v0.7.2

func (c *PostgresCacher) Name() string

func (*PostgresCacher) Put

func (c *PostgresCacher) Put(ctx context.Context, key string, val interface{}, expire int64) error

Put puts value into cache with key and expire time. If expired is 0, it will be deleted by next GC operation.

func (*PostgresCacher) SetCodec

func (c *PostgresCacher) SetCodec(codec encoding.Codec)

func (*PostgresCacher) StartAndGC

func (c *PostgresCacher) StartAndGC(ctx context.Context, opt cache.Options) (err error)

StartAndGC starts GC routine based on config string settings.

Jump to

Keyboard shortcuts

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