Closed dulumao closed 4 years ago
可以直接用最普通的缓存方式:
func GetMember(id int64) (member *DtbMemberModel, err error) {
cacheName := fmt.Sprintf("DtbMember:ID:%d", id)
if member = cache.Instance().Get(cacheName); member != nil {
return
}
if _, err = db.SelectFrom(DtbMember).
Where(DtbMember.Id.Equals(id)).
FetchFirst(&member); err != nil {
return
}
if member != nil {
cache.Instance().Put(cacheName, member)
}
return
}
谢谢啦
I want to add a Cache-function, Currently like this, is there any other simplified way