缓存测试成功
This commit is contained in:
Vendored
+19
-19
@@ -20,7 +20,7 @@ func (that *HoTimeCache) Session(key string, data ...interface{}) *Obj {
|
||||
if len(data) == 0 {
|
||||
//内存缓存有
|
||||
if that.memoryCache != nil && that.memoryCache.SessionSet {
|
||||
reData = that.memoryCache.Cache(key, data)
|
||||
reData = that.memoryCache.Cache(key, data...)
|
||||
if reData != nil {
|
||||
return reData
|
||||
}
|
||||
@@ -28,7 +28,7 @@ func (that *HoTimeCache) Session(key string, data ...interface{}) *Obj {
|
||||
|
||||
//redis缓存有
|
||||
if that.redisCache != nil && that.redisCache.SessionSet {
|
||||
reData = that.redisCache.Cache(key, data)
|
||||
reData = that.redisCache.Cache(key, data...)
|
||||
if reData != nil {
|
||||
if that.memoryCache != nil && that.memoryCache.SessionSet {
|
||||
that.memoryCache.Cache(key, reData)
|
||||
@@ -39,7 +39,7 @@ func (that *HoTimeCache) Session(key string, data ...interface{}) *Obj {
|
||||
|
||||
//db缓存有
|
||||
if that.dbCache != nil && that.dbCache.SessionSet {
|
||||
reData = that.dbCache.Cache(key, data)
|
||||
reData = that.dbCache.Cache(key, data...)
|
||||
if reData != nil {
|
||||
if that.memoryCache != nil && that.memoryCache.SessionSet {
|
||||
that.memoryCache.Cache(key, reData)
|
||||
@@ -57,15 +57,15 @@ func (that *HoTimeCache) Session(key string, data ...interface{}) *Obj {
|
||||
//设置缓存
|
||||
//设置内存缓存
|
||||
if that.memoryCache != nil && that.memoryCache.SessionSet {
|
||||
reData = that.memoryCache.Cache(key, data)
|
||||
reData = that.memoryCache.Cache(key, data...)
|
||||
}
|
||||
//redis缓存有
|
||||
if that.redisCache != nil && that.redisCache.SessionSet {
|
||||
reData = that.redisCache.Cache(key, data)
|
||||
reData = that.redisCache.Cache(key, data...)
|
||||
}
|
||||
//redis缓存有
|
||||
if that.dbCache != nil && that.dbCache.SessionSet {
|
||||
reData = that.dbCache.Cache(key, data)
|
||||
reData = that.dbCache.Cache(key, data...)
|
||||
}
|
||||
return reData
|
||||
|
||||
@@ -75,7 +75,7 @@ func (that *HoTimeCache) Db(key string, data ...interface{}) *Obj {
|
||||
if len(data) == 0 {
|
||||
//内存缓存有
|
||||
if that.memoryCache != nil && that.memoryCache.DbSet {
|
||||
reData = that.memoryCache.Cache(key, data)
|
||||
reData = that.memoryCache.Cache(key, data...)
|
||||
if reData != nil {
|
||||
return reData
|
||||
}
|
||||
@@ -83,7 +83,7 @@ func (that *HoTimeCache) Db(key string, data ...interface{}) *Obj {
|
||||
|
||||
//redis缓存有
|
||||
if that.redisCache != nil && that.redisCache.DbSet {
|
||||
reData = that.redisCache.Cache(key, data)
|
||||
reData = that.redisCache.Cache(key, data...)
|
||||
if reData != nil {
|
||||
if that.memoryCache != nil && that.memoryCache.DbSet {
|
||||
that.memoryCache.Cache(key, reData)
|
||||
@@ -94,7 +94,7 @@ func (that *HoTimeCache) Db(key string, data ...interface{}) *Obj {
|
||||
|
||||
//redis缓存有
|
||||
if that.dbCache != nil && that.dbCache.DbSet {
|
||||
reData = that.dbCache.Cache(key, data)
|
||||
reData = that.dbCache.Cache(key, data...)
|
||||
if reData != nil {
|
||||
if that.memoryCache != nil && that.memoryCache.DbSet {
|
||||
that.memoryCache.Cache(key, reData)
|
||||
@@ -113,15 +113,15 @@ func (that *HoTimeCache) Db(key string, data ...interface{}) *Obj {
|
||||
//设置缓存
|
||||
//设置内存缓存
|
||||
if that.memoryCache != nil && that.memoryCache.DbSet {
|
||||
reData = that.memoryCache.Cache(key, data)
|
||||
reData = that.memoryCache.Cache(key, data...)
|
||||
}
|
||||
//redis缓存有
|
||||
if that.redisCache != nil && that.redisCache.DbSet {
|
||||
reData = that.redisCache.Cache(key, data)
|
||||
reData = that.redisCache.Cache(key, data...)
|
||||
}
|
||||
//redis缓存有
|
||||
if that.dbCache != nil && that.dbCache.DbSet {
|
||||
reData = that.dbCache.Cache(key, data)
|
||||
reData = that.dbCache.Cache(key, data...)
|
||||
}
|
||||
return reData
|
||||
}
|
||||
@@ -131,7 +131,7 @@ func (that *HoTimeCache) Cache(key string, data ...interface{}) *Obj {
|
||||
if len(data) == 0 {
|
||||
//内存缓存有
|
||||
if that.memoryCache != nil {
|
||||
reData = that.memoryCache.Cache(key, data)
|
||||
reData = that.memoryCache.Cache(key, data...)
|
||||
if reData != nil {
|
||||
return reData
|
||||
}
|
||||
@@ -139,7 +139,7 @@ func (that *HoTimeCache) Cache(key string, data ...interface{}) *Obj {
|
||||
|
||||
//redis缓存有
|
||||
if that.redisCache != nil {
|
||||
reData = that.redisCache.Cache(key, data)
|
||||
reData = that.redisCache.Cache(key, data...)
|
||||
if reData != nil {
|
||||
|
||||
if that.memoryCache != nil {
|
||||
@@ -151,7 +151,7 @@ func (that *HoTimeCache) Cache(key string, data ...interface{}) *Obj {
|
||||
|
||||
//redis缓存有
|
||||
if that.dbCache != nil {
|
||||
reData = that.dbCache.Cache(key, data)
|
||||
reData = that.dbCache.Cache(key, data...)
|
||||
if reData != nil {
|
||||
if that.memoryCache != nil {
|
||||
that.memoryCache.Cache(key, reData)
|
||||
@@ -168,15 +168,15 @@ func (that *HoTimeCache) Cache(key string, data ...interface{}) *Obj {
|
||||
//设置缓存
|
||||
//设置内存缓存
|
||||
if that.memoryCache != nil {
|
||||
reData = that.memoryCache.Cache(key, data)
|
||||
reData = that.memoryCache.Cache(key, data...)
|
||||
}
|
||||
//redis缓存有
|
||||
if that.redisCache != nil {
|
||||
reData = that.redisCache.Cache(key, data)
|
||||
reData = that.redisCache.Cache(key, data...)
|
||||
}
|
||||
//redis缓存有
|
||||
if that.dbCache != nil {
|
||||
reData = that.dbCache.Cache(key, data)
|
||||
reData = that.dbCache.Cache(key, data...)
|
||||
}
|
||||
return reData
|
||||
}
|
||||
@@ -237,7 +237,7 @@ func (that *HoTimeCache) Init(config Map, hotimeDb HoTimeDBInterface, err ...*Er
|
||||
}
|
||||
|
||||
if redis.Get("timeout") == nil {
|
||||
redis["timeout"] = 60 * 60 * 24 * 30
|
||||
redis["timeout"] = 60 * 60 * 24 * 15
|
||||
}
|
||||
that.Config["redis"] = redis
|
||||
that.redisCache = &CacheRedis{TimeOut: redis.GetCeilInt64("timeout"),
|
||||
|
||||
Vendored
+2
-3
@@ -23,7 +23,6 @@ type CacheDb struct {
|
||||
TimeOut int64
|
||||
DbSet bool
|
||||
SessionSet bool
|
||||
Time int64
|
||||
Db HoTimeDBInterface
|
||||
*Error
|
||||
ContextBase
|
||||
@@ -152,10 +151,10 @@ func (that *CacheDb) Cache(key string, data ...interface{}) *Obj {
|
||||
}
|
||||
|
||||
if len(data) == 1 {
|
||||
if that.Time == 0 {
|
||||
if that.TimeOut == 0 {
|
||||
//that.Time = Config.GetInt64("cacheLongTime")
|
||||
}
|
||||
tim += that.Time
|
||||
tim += that.TimeOut
|
||||
}
|
||||
if len(data) == 2 {
|
||||
that.SetError(nil)
|
||||
|
||||
Vendored
+8
-5
@@ -48,12 +48,15 @@ func (this *CacheRedis) reCon() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
_, err = this.conn.Do("AUTH", this.Pwd)
|
||||
if err != nil {
|
||||
this.conn = nil
|
||||
this.Error.SetError(err)
|
||||
return false
|
||||
if this.Pwd != "" {
|
||||
_, err = this.conn.Do("AUTH", this.Pwd)
|
||||
if err != nil {
|
||||
this.conn = nil
|
||||
this.Error.SetError(err)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
func (this *CacheRedis) del(key string) {
|
||||
|
||||
Reference in New Issue
Block a user