config

package
v0.0.0-...-7bd0bfa Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CacheConfig

type CacheConfig struct {
	// CacheLevel there're 2 types of cache and 4 kinds of cache option
	CacheLevel CacheLevel

	// CacheStorage choose proper storage medium
	CacheStorage CacheStorage

	// RedisConfig if storage is redis, then this config needs to be setup
	RedisConfig *RedisConfig

	// Tables only cache data within given data tables (cache all if empty)
	Tables []string

	// InvalidateWhenUpdate
	// if user update/delete/create something in DB, we invalidate all cached data to ensure consistency,
	// else we do nothing to outdated cache.
	InvalidateWhenUpdate bool

	// CacheTTL cache ttl in ms, where 0 represents forever
	CacheTTL int64

	// CacheMaxItemCnt for given query, if objects retrieved are more than this cnt,
	// then we choose not to cache for this query. 0 represents caching all queries.
	CacheMaxItemCnt int64

	// CacheSize maximal items in primary cache (only works in MEMORY storage)
	CacheSize int

	// DebugMode indicate if we're in debug mode (will print access log)
	DebugMode bool

	// DebugLogger
	DebugLogger LoggerInterface
}

type CacheLevel

type CacheLevel int
const (
	CacheLevelOff         CacheLevel = 0
	CacheLevelOnlyPrimary CacheLevel = 1
	CacheLevelOnlySearch  CacheLevel = 2
	CacheLevelAll         CacheLevel = 3
)

type CacheStorage

type CacheStorage int
const (
	CacheStorageMemory CacheStorage = 0
	CacheStorageRedis  CacheStorage = 1
)

type DefaultLoggerImpl

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

func (*DefaultLoggerImpl) CtxError

func (l *DefaultLoggerImpl) CtxError(ctx context.Context, format string, v ...interface{})

func (*DefaultLoggerImpl) CtxInfo

func (l *DefaultLoggerImpl) CtxInfo(ctx context.Context, format string, v ...interface{})

func (*DefaultLoggerImpl) SetIsDebug

func (l *DefaultLoggerImpl) SetIsDebug(d bool)

type LoggerInterface

type LoggerInterface interface {
	SetIsDebug(debug bool)
	CtxInfo(ctx context.Context, format string, v ...interface{})
	CtxError(ctx context.Context, format string, v ...interface{})
}

type RedisConfig

type RedisConfig struct {
	Mode RedisConfigMode

	Options *redis.Options
	Client  *redis.Client
	// contains filtered or unexported fields
}

func (*RedisConfig) InitClient

func (c *RedisConfig) InitClient() *redis.Client

type RedisConfigMode

type RedisConfigMode int
const (
	RedisConfigModeOptions RedisConfigMode = 0
	RedisConfigModeRaw     RedisConfigMode = 1
)

Jump to

Keyboard shortcuts

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