开启缓存后缓存的key是不可见字符 #1511

Open
opened 2020-01-16 17:15:55 +00:00 by cyanBone · 1 comment

config:

configs := map[string]string{
	"conn": Cfg.RedisAddr,
	"key":  "default", // the collection name of redis for cache adapter.
}
ccStore := cachestore.NewRedisCache(configs)
ccStore.Debug = true
cacher := xorm.NewLRUCacher(ccStore, 99999999)
//db.SetDefaultCacher(cacher)

//cacher := xorm.NewLRUCacher(xorm.NewMemoryStore(), 1000)
db.SetDefaultCacher(cacher)

action:

type Category struct {
	Id          int64   `json:"id"`
	Name        string  `xorm:"varchar(50) notnull default '' index"`
	Description string  `xorm:"varchar(255) notnull default ''"`
	Image       string  `xorm:"varchar(255) notnull default ''"`
	Price       float32 `xorm:"notnull default 0"`
	CreatedAt   int64   `xorm:"created notnull default 0"`
	UpdatedAt   int64   `xorm:"updated notnull default 0"`
}


func (c *Category) Page(p int) (cas []Category, err error) {
	err = GetDb().Desc("id").Limit(PageSize*p, (p-1)*PageSize).Find(&cas)
	return
}
config: ```go configs := map[string]string{ "conn": Cfg.RedisAddr, "key": "default", // the collection name of redis for cache adapter. } ccStore := cachestore.NewRedisCache(configs) ccStore.Debug = true cacher := xorm.NewLRUCacher(ccStore, 99999999) //db.SetDefaultCacher(cacher) //cacher := xorm.NewLRUCacher(xorm.NewMemoryStore(), 1000) db.SetDefaultCacher(cacher) ``` action: ```go type Category struct { Id int64 `json:"id"` Name string `xorm:"varchar(50) notnull default '' index"` Description string `xorm:"varchar(255) notnull default ''"` Image string `xorm:"varchar(255) notnull default ''"` Price float32 `xorm:"notnull default 0"` CreatedAt int64 `xorm:"created notnull default 0"` UpdatedAt int64 `xorm:"updated notnull default 0"` } func (c *Category) Page(p int) (cas []Category, err error) { err = GetDb().Desc("id").Limit(PageSize*p, (p-1)*PageSize).Find(&cas) return } ```
lunny added the
need
test
label 2020-01-17 01:33:53 +00:00
lunny added
kind
question
and removed
need
test
labels 2020-03-27 08:29:06 +00:00
Owner

The cache key is crc charactors.

The cache key is crc charactors.
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: xorm/xorm#1511
No description provided.