gfcache

package
v0.0.0-...-2cadf5c Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: Apache-2.0 Imports: 11 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	RecordNotFound = errors.New("record not found")
	CacheNotFound  = errors.New("cache not found")
)

Functions

This section is empty.

Types

type Cache

type Cache interface {
	HasCache(key string) bool
	GetCache(key string, data interface{}) error
	SetCache(key string, data interface{}) error
	DelCache(key string) error
}

type CacheClearFunc

type CacheClearFunc func(cache Cache) error

type CacheGetSetFunc

type CacheGetSetFunc func(cache Cache, dest interface{}) error

type LocalCache

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

func NewLocalCache

func NewLocalCache(timeout time.Duration) *LocalCache

func (*LocalCache) DelCache

func (c *LocalCache) DelCache(key string) error

func (*LocalCache) GetCache

func (c *LocalCache) GetCache(key string, data interface{}) error

func (*LocalCache) HasCache

func (c *LocalCache) HasCache(key string) bool

func (*LocalCache) Serial

func (c *LocalCache) Serial(serial gfserial.Serializer) *LocalCache

func (*LocalCache) SetCache

func (c *LocalCache) SetCache(key string, data interface{}) error

type MultiCache

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

func NewMultiCache

func NewMultiCache(caches ...Cache) *MultiCache

func (*MultiCache) Append

func (c *MultiCache) Append(cache Cache) *MultiCache

func (*MultiCache) DelCache

func (c *MultiCache) DelCache(key string) error

func (*MultiCache) DelCacheFromLevel

func (c *MultiCache) DelCacheFromLevel(key string, levelIdx int) error

func (*MultiCache) GetCache

func (c *MultiCache) GetCache(key string, data interface{}) error

func (*MultiCache) HasCache

func (c *MultiCache) HasCache(key string) bool

func (*MultiCache) SetCache

func (c *MultiCache) SetCache(key string, data interface{}) error

type RedigoCache

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

func NewRedigoCache

func NewRedigoCache(redis *redis.Pool) *RedigoCache

func (*RedigoCache) DelCache

func (c *RedigoCache) DelCache(key string) error

func (*RedigoCache) GetCache

func (c *RedigoCache) GetCache(key string, data interface{}) error

func (*RedigoCache) HasCache

func (c *RedigoCache) HasCache(key string) bool

func (*RedigoCache) NilFlag

func (c *RedigoCache) NilFlag(nilFlag string) *RedigoCache

func (*RedigoCache) NilTime

func (c *RedigoCache) NilTime(nilTime time.Duration) *RedigoCache

func (*RedigoCache) Serial

func (c *RedigoCache) Serial(serial gfserial.Serializer) *RedigoCache

func (*RedigoCache) SetCache

func (c *RedigoCache) SetCache(key string, data interface{}) error

func (*RedigoCache) Timeout

func (c *RedigoCache) Timeout(timeout time.Duration) *RedigoCache

type RedisCache

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

func NewRedisCache

func NewRedisCache(redis *redis.Client) *RedisCache

func (*RedisCache) DelCache

func (c *RedisCache) DelCache(key string) error

func (*RedisCache) GetCache

func (c *RedisCache) GetCache(key string, data interface{}) error

func (*RedisCache) HasCache

func (c *RedisCache) HasCache(key string) bool

func (*RedisCache) NilFlag

func (c *RedisCache) NilFlag(nilFlag string) *RedisCache

func (*RedisCache) NilTime

func (c *RedisCache) NilTime(nilTime time.Duration) *RedisCache

func (*RedisCache) Serial

func (c *RedisCache) Serial(serial gfserial.Serializer) *RedisCache

func (*RedisCache) SetCache

func (c *RedisCache) SetCache(key string, data interface{}) error

func (*RedisCache) Timeout

func (c *RedisCache) Timeout(timeout time.Duration) *RedisCache

type SourceDB

type SourceDB interface {
	Query(ctx context.Context, dest interface{}, query string, args ...interface{}) error
	Execute(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
}

type SourceDBTx

type SourceDBTx[T Transaction] interface {
	Transact(ctx context.Context, txFn TransactFunc[T]) error
	SourceDB() SourceDB
}

type SqlCache

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

func NewSqlCache

func NewSqlCache(db SourceDB, cache Cache) *SqlCache

func (*SqlCache) Execute

func (c *SqlCache) Execute(ctx context.Context, clearKeys []string, query string, args ...interface{}) (sql.Result, error)

func (*SqlCache) ExecuteWithFunc

func (c *SqlCache) ExecuteWithFunc(ctx context.Context, clearFn CacheClearFunc, query string, args ...interface{}) (sql.Result, error)

func (*SqlCache) Query

func (c *SqlCache) Query(ctx context.Context, cacheKey string, dest interface{}, query string, args ...interface{}) error

func (*SqlCache) QueryWithFunc

func (c *SqlCache) QueryWithFunc(ctx context.Context, getFn, setFn CacheGetSetFunc, dest interface{}, query string, args ...interface{}) error

type SqlCacheTx

type SqlCacheTx[T Transaction] struct {
	SqlCache
	// contains filtered or unexported fields
}

func NewSqlCacheTx

func NewSqlCacheTx[T Transaction](db SourceDBTx[T], cache Cache) *SqlCacheTx[T]

func (*SqlCacheTx[T]) Transact

func (c *SqlCacheTx[T]) Transact(ctx context.Context, clearFn CacheClearFunc, txFn TransactFunc[T]) error

type SqlxDB

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

func NewSqlxDB

func NewSqlxDB(db *sqlx.DB) *SqlxDB

func (*SqlxDB) Execute

func (d *SqlxDB) Execute(ctx context.Context, query string, args ...interface{}) (sql.Result, error)

func (*SqlxDB) Query

func (d *SqlxDB) Query(ctx context.Context, dest interface{}, query string, args ...interface{}) error

func (*SqlxDB) SourceDB

func (d *SqlxDB) SourceDB() SourceDB

func (*SqlxDB) Transact

func (d *SqlxDB) Transact(ctx context.Context, txFn TransactFunc[*sqlx.Tx]) (retErr error)

type TransactFunc

type TransactFunc[T Transaction] func(tx T) error

type Transaction

type Transaction interface {
	Commit() error
	Rollback() error
}

Jump to

Keyboard shortcuts

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