Documentation ¶
Index ¶
- func Debug(debug ...bool)
- func NewLocalCache() *localCache
- func NewRedisCache() *redisCache
- func RedisCacheInit(host, port, auth string, module ...string)
- func RegisterCache(c Cache)
- func SETExpire(e int)
- func SetDebug(debug ...bool)
- type Cache
- type Dao
- func (d *Dao) ClearCache()
- func (d *Dao) Create(data interface{}) (int64, error)
- func (d *Dao) DB() *gorm.DB
- func (d *Dao) DryRun() *gorm.DB
- func (d *Dao) EXEC() (int64, error)
- func (d *Dao) Fetch(result interface{}) error
- func (d *Dao) PrepareSql(sql string, params ...interface{}) Daoer
- func (d *Dao) SetKey(key string) Daoer
- func (d *Dao) SetTag(tag string) Daoer
- type Daoer
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewLocalCache ¶
func NewLocalCache() *localCache
func NewRedisCache ¶
func NewRedisCache() *redisCache
func RedisCacheInit ¶
Types ¶
type Dao ¶
type Dao struct {
// contains filtered or unexported fields
}
func (*Dao) ClearCache ¶
func (d *Dao) ClearCache()
func (*Dao) Fetch ¶
Example ¶
db := NewDb() var user1 User db.DB().AutoMigrate(&User{}) stmt := db.DryRun().Find(&user1, 1).Statement tag := "users000" err := db.SetTag(tag).PrepareSql(stmt.SQL.String(), stmt.Vars...).Fetch(&user1) fmt.Println(user1.Id, err) var users []User // 会话模式 stmt = db.DryRun().Find(&users).Statement db.SetTag(tag).PrepareSql(stmt.SQL.String(), stmt.Vars...).Fetch(&users) fmt.Println("result", len(users) > 0)
Output: 1 <nil> result true
func (*Dao) PrepareSql ¶
Click to show internal directories.
Click to hide internal directories.