Documentation
¶
Index ¶
- Constants
- Variables
- func ContainString(target string, slice []string) bool
- func GenInstanceId() string
- func GenPrimaryCacheKey(instanceId string, tableName string, primaryKeyValues ...string) string
- func GenPrimaryCacheKeyFromMap(instanceId string, tableName string, primaryKeyMap map[string]string) string
- func GenPrimaryCachePrefix(instanceId string, tableName string) string
- func GenSearchCacheKey(instanceId string, tableName string, sql string, vars ...interface{}) string
- func GenSearchCachePrefix(instanceId string, tableName string) string
- func GenSingleFlightKey(tableName string, sql string, vars ...interface{}) string
- func GenUniqueCacheKey(instanceId string, tableName string, uniqueIndexName string, ...) string
- func GenUniqueCacheKeyFromMap(instanceId string, tableName string, uniqueIndexName string, ...) string
- func GenUniqueCachePrefix(instanceId string, tableName string, uniqueIndexName string) string
- func RandFloatingInt64(v int64) int64
- func ShouldCache(tableName string, tables []string) bool
- type DefaultLogger
- type Kv
- type LoggerInterface
Constants ¶
View Source
const (
GormCachePrefix = "gormcache"
)
Variables ¶
View Source
var ErrCacheLoadFailed = errors.New("cache hit, but load value error")
View Source
var ErrCacheUnmarshal = errors.New("cache hit, but unmarshal error")
View Source
var PrimaryCacheHit = errors.New("primary cache hit")
View Source
var RecordNotFoundCacheHit = errors.New("record not found cache hit")
View Source
var SearchCacheHit = errors.New("search cache hit")
View Source
var SingleFlightHit = errors.New("single flight hit")
Functions ¶
func ContainString ¶
func GenInstanceId ¶
func GenInstanceId() string
func GenPrimaryCacheKey ¶
GenPrimaryCacheKey 生成主键缓存key,支持单个主键和联合主键 联合主键各段会做 base64 编码,避免含 ":" 的值产生 key 碰撞
func GenPrimaryCacheKeyFromMap ¶ added in v1.3.0
func GenPrimaryCacheKeyFromMap(instanceId string, tableName string, primaryKeyMap map[string]string) string
GenPrimaryCacheKeyFromMap 从map生成主键缓存key,支持联合主键 primaryKeyMap: key为字段名,value为字段值,会自动按字段名排序以保证一致性
func GenPrimaryCachePrefix ¶
func GenSearchCacheKey ¶
func GenSearchCachePrefix ¶
func GenSingleFlightKey ¶ added in v1.1.1
func GenUniqueCacheKey ¶ added in v1.3.0
func GenUniqueCacheKey(instanceId string, tableName string, uniqueIndexName string, uniqueKeyValues ...string) string
GenUniqueCacheKey 生成unique键缓存key,支持单个unique键和联合unique键 联合unique键各段会做 base64 编码,避免含 ":" 的值产生 key 碰撞
func GenUniqueCacheKeyFromMap ¶ added in v1.3.0
func GenUniqueCacheKeyFromMap(instanceId string, tableName string, uniqueIndexName string, uniqueKeyMap map[string]string) string
GenUniqueCacheKeyFromMap 从map生成unique键缓存key,支持联合unique键 uniqueKeyMap: key为字段名,value为字段值,会自动按字段名排序以保证一致性
func GenUniqueCachePrefix ¶ added in v1.3.0
GenUniqueCachePrefix 生成unique键缓存前缀
func RandFloatingInt64 ¶
func ShouldCache ¶
Types ¶
type DefaultLogger ¶
type DefaultLogger struct {
// contains filtered or unexported fields
}
func (*DefaultLogger) CtxError ¶
func (l *DefaultLogger) CtxError(ctx context.Context, format string, v ...interface{})
func (*DefaultLogger) CtxInfo ¶
func (l *DefaultLogger) CtxInfo(ctx context.Context, format string, v ...interface{})
func (*DefaultLogger) SetIsDebug ¶
func (l *DefaultLogger) SetIsDebug(d bool)
Click to show internal directories.
Click to hide internal directories.