Documentation ¶
Index ¶
- type CacheHandler
- func (c CacheHandler) DelEntries(entrySlice interface{}, sql string, args ...interface{}) error
- func (c CacheHandler) GetEntries(entrySlice interface{}, sql string, args ...interface{}) error
- func (c CacheHandler) GetEntriesAndCount(entries interface{}, sql string, args ...interface{}) (int64, error)
- func (c CacheHandler) GetEntriesByIds(entries interface{}, entrySliceIds interface{}) error
- func (c CacheHandler) GetEntry(entry interface{}) (bool, error)
- type DefaultLogger
- type EntryCache
- type ICache
- type ICacheHandler
- type IDB
- type JsonSerializer
- type KeyValue
- type Logger
- type Options
- type OptionsFunc
- type ReturnKeyValue
- type Serializer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CacheHandler ¶
type CacheHandler struct {
// contains filtered or unexported fields
}
CacheHandler Default Cache handler
func NewCacheHandler ¶
func NewCacheHandler(cacheHandler ICache, databaseHandler IDB, options ...OptionsFunc) *CacheHandler
NewCacheHandler Create a Cache handler
func (CacheHandler) DelEntries ¶
func (c CacheHandler) DelEntries(entrySlice interface{}, sql string, args ...interface{}) error
DelEntries Delete cache via sql
func (CacheHandler) GetEntries ¶
func (c CacheHandler) GetEntries(entrySlice interface{}, sql string, args ...interface{}) error
GetEntries Get the list of cached entities
func (CacheHandler) GetEntriesAndCount ¶ added in v0.2.3
func (c CacheHandler) GetEntriesAndCount(entries interface{}, sql string, args ...interface{}) (int64, error)
GetEntriesAndCount Get the cache list with the total
func (CacheHandler) GetEntriesByIds ¶ added in v0.2.18
func (c CacheHandler) GetEntriesByIds(entries interface{}, entrySliceIds interface{}) error
func (CacheHandler) GetEntry ¶
func (c CacheHandler) GetEntry(entry interface{}) (bool, error)
GetEntry Get cached entity
type DefaultLogger ¶ added in v0.2.7
type DefaultLogger struct { }
DefaultLogger Default log component
func (DefaultLogger) Debug ¶ added in v0.2.7
func (d DefaultLogger) Debug(format string, a ...interface{})
Debug Debug category log
func (DefaultLogger) Error ¶ added in v0.2.7
func (d DefaultLogger) Error(format string, a ...interface{})
Error Error category log
func (DefaultLogger) Info ¶ added in v0.2.7
func (d DefaultLogger) Info(format string, a ...interface{})
Info Info category log
func (DefaultLogger) Warn ¶ added in v0.2.7
func (d DefaultLogger) Warn(format string, a ...interface{})
Warn Warn category log
type EntryCache ¶
type EntryCache struct {
// contains filtered or unexported fields
}
EntryCache Cache entity
type ICache ¶
type ICache interface { // StoreAll Store all key-value pairs StoreAll(keyValues ...KeyValue) (err error) // Get value by key Get(key string) (data []byte, has bool, err error) // GetAll values by keys GetAll(keys schemas.PK) (data []ReturnKeyValue, err error) // DeleteAll delete all keys DeleteAll(keys schemas.PK) error }
ICache Cache abstraction
type ICacheHandler ¶
type ICacheHandler interface { // GetEntry get a pointer to an entity type and return the entity GetEntry(entry interface{}) (bool, error) // GetEntriesByIds cache the entity content obtained through ids, and return the entity of the array pointer type GetEntriesByIds(entries interface{}, entrySliceIds interface{}) error // GetEntries cache the entity content obtained through sql, and return the entity of the array pointer type GetEntries(entrySlice interface{}, sql string, args ...interface{}) error // GetEntriesAndCount cache the entity content obtained through sql, and return the entity of the array pointer type, and return the total quantity GetEntriesAndCount(entries interface{}, sql string, args ...interface{}) (int64, error) // DelEntries delete the corresponding execution entity through sql, // Before the update, you can query the id to be deleted first, and then delete these through defer DelEntries(entrySlice interface{}, sql string, args ...interface{}) error }
ICacheHandler Cache handler abstraction
type IDB ¶
type IDB interface { // GetEntries cache the entity content obtained through sql, and return the entity of the array pointer type GetEntries(entries interface{}, sql string) error // GetEntry get a pointer to an entity type and return the entity GetEntry(entry interface{}, sql string) (bool, error) }
IDB Database abstraction
type JsonSerializer ¶
type JsonSerializer struct { }
JsonSerializer json serializer
func (JsonSerializer) Deserialize ¶
func (j JsonSerializer) Deserialize(data []byte, ptr interface{}) error
Deserialize Deserialize
func (JsonSerializer) Serialize ¶
func (j JsonSerializer) Serialize(value interface{}) ([]byte, error)
Serialize Serialize
type Logger ¶ added in v0.2.7
type Logger interface { // Info Info category log Info(format string, a ...interface{}) // Error Error category log Error(format string, a ...interface{}) // Debug Debug category log Debug(format string, a ...interface{}) // Warn Warn category log Warn(format string, a ...interface{}) }
Logger Log component
type OptionsFunc ¶
type OptionsFunc func(o *Options)
OptionsFunc Alternative method
func WithCacheTagName ¶
func WithCacheTagName(cacheTagName string) OptionsFunc
WithCacheTagName Specify cache tag name
func WithSerializer ¶
func WithSerializer(serializer Serializer) OptionsFunc
WithSerializer Specify the serialization method
func WithServiceName ¶ added in v0.2.0
func WithServiceName(serviceName string) OptionsFunc
WithServiceName Service Name
type ReturnKeyValue ¶
ReturnKeyValue Return the key and value of the entity through the cache