rkcache

package module
v0.0.0-...-df2ac0d Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

README

rk-cache

Cache entry which used in rk-boot.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCache

func GetCache(entryName string) *cache.Cache

GetCache get cache.Cache with entryName

func RegisterCacheEntryFromConfig

func RegisterCacheEntryFromConfig(configFilePath string) map[string]rkentry.Entry

RegisterCacheEntryFromConfig create entry from config file

Types

type BootConfig

type BootConfig struct {
	Cache []struct {
		Name        string `yaml:"name" json:"name"`
		Description string `yaml:"description" json:"description"`
		Enabled     bool   `yaml:"enabled" json:"enabled"`
		Local       struct {
			Enabled bool `yaml:"enabled" json:"enabled"`
			Size    int  `yaml:"size" json:"size"`
			TtlMin  int  `yaml:"ttlMin" json:"ttlMin"`
		} `yaml:"local" json:"local"`
		Redis  rkredis.BootConfigRedis `yaml:"redis" json:"redis"`
		Logger struct {
			ZapLogger string `yaml:"zapLogger" json:"zapLogger"`
		} `yaml:"logger" json:"logger"`
		Cert struct {
			Ref string `yaml:"ref" json:"ref"`
		} `yaml:"cert" json:"cert"`
	} `yaml:"cache" json:"cache"`
}

BootConfig bootstrap entry from config

type CacheEntry

type CacheEntry struct {
	EntryName        string
	EntryType        string
	EntryDescription string
	// contains filtered or unexported fields
}

CacheEntry implementation of rkentry.Entry

func GetCacheEntry

func GetCacheEntry(entryName string) *CacheEntry

func RegisterCacheEntry

func RegisterCacheEntry(opts ...Option) *CacheEntry

RegisterCacheEntry register with Option

func (*CacheEntry) AddToCacheEncoded

func (entry *CacheEntry) AddToCacheEncoded(req *CacheReq) *CacheResp

func (*CacheEntry) Bootstrap

func (entry *CacheEntry) Bootstrap(ctx context.Context)

Bootstrap entry

func (*CacheEntry) GetCache

func (entry *CacheEntry) GetCache() *cache.Cache

GetCache returns cache instance

func (*CacheEntry) GetDescription

func (entry *CacheEntry) GetDescription() string

GetDescription returns description of entry

func (*CacheEntry) GetFromCacheEncoded

func (entry *CacheEntry) GetFromCacheEncoded(req *CacheReq) *CacheResp

func (*CacheEntry) GetName

func (entry *CacheEntry) GetName() string

GetName returns name of entry

func (*CacheEntry) GetType

func (entry *CacheEntry) GetType() string

GetType returns type of entry

func (*CacheEntry) Interrupt

func (entry *CacheEntry) Interrupt(ctx context.Context)

Interrupt entry

func (*CacheEntry) IsLocalCacheEnabled

func (entry *CacheEntry) IsLocalCacheEnabled() bool

IsLocalCacheEnabled is local cache enabled

func (*CacheEntry) IsRedisCacheEnabled

func (entry *CacheEntry) IsRedisCacheEnabled() bool

IsRedisCacheEnabled is redis cache enabled

func (*CacheEntry) String

func (entry *CacheEntry) String() string

String to string

type CacheReq

type CacheReq struct {
	Key   interface{}
	Value interface{}
}

type CacheResp

type CacheResp struct {
	Success bool
	Error   error
}

type Option

type Option func(e *CacheEntry)

Option entry options

func WithDescription

func WithDescription(description string) Option

WithDescription provide name.

func WithLocalCache

func WithLocalCache(in cache.LocalCache) Option

WithLocalCache provide LocalCache

func WithName

func WithName(name string) Option

WithName provide name.

func WithRedisCache

func WithRedisCache(in *rkredis.RedisEntry) Option

WithRedisCache provide RedisEntry

func WithZapLoggerEntry

func WithZapLoggerEntry(entry *rkentry.ZapLoggerEntry) Option

WithZapLoggerEntry provide rkentry.ZapLoggerEntry entry name

Directories

Path Synopsis
redis module

Jump to

Keyboard shortcuts

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