I currently develop golang projects with xorm.
I want to use a cache to manage the result of sql queries called once. I expected that sql requests would be called once, and would not be called again, but they do get called again.
Also, Redis keys that get created do not appear in redis-cli(keys *).
Why are my sql queries getting called more than once?
package main
import (
"github.com/go-xorm/xorm"
_ "github.com/go-sql-driver/mysql"
xrc "github.com/go-xorm/xorm-redis-cache"
)
type User struct {
Id int
Name string
}
func main() {
engine, err := xorm.NewEngine("mysql", "root:@/xorm_test_db")
if nil != err {
log.Fatal(err)
}
engine.ShowSQL(true)
cacher := xrc.NewRedisCacher("localhost:6379", "", xrc.DEFAULT_EXPIRATION, engine.Logger())
engine.SetDefaultCacher(cacher)
engine.Get(User{Id: 1})
engine.Get(User{Id: 1})
}