mirror of
https://github.com/astaxie/beego.git
synced 2024-11-26 06:11:29 +00:00
code style simplify
This commit is contained in:
parent
8683ee7c67
commit
0b1b121db8
10
cache/file.go
vendored
10
cache/file.go
vendored
@ -135,11 +135,11 @@ func (fc *FileCache) Get(key string) interface{} {
|
|||||||
func (fc *FileCache) Put(key string, val interface{}, timeout int64) error {
|
func (fc *FileCache) Put(key string, val interface{}, timeout int64) error {
|
||||||
gob.Register(val)
|
gob.Register(val)
|
||||||
|
|
||||||
item := FileCacheItem{Data:val}
|
item := FileCacheItem{Data: val}
|
||||||
if timeout == FileCacheEmbedExpiry {
|
if timeout == FileCacheEmbedExpiry {
|
||||||
item.Expired = time.Now().Unix()+(86400*365*10) // ten years
|
item.Expired = time.Now().Unix() + (86400 * 365 * 10) // ten years
|
||||||
} else {
|
} else {
|
||||||
item.Expired = time.Now().Unix()+timeout
|
item.Expired = time.Now().Unix() + timeout
|
||||||
}
|
}
|
||||||
item.Lastaccess = time.Now().Unix()
|
item.Lastaccess = time.Now().Unix()
|
||||||
data, err := Gob_encode(item)
|
data, err := Gob_encode(item)
|
||||||
@ -166,7 +166,7 @@ func (fc *FileCache) Incr(key string) error {
|
|||||||
if reflect.TypeOf(data).Name() != "int" {
|
if reflect.TypeOf(data).Name() != "int" {
|
||||||
incr = 0
|
incr = 0
|
||||||
} else {
|
} else {
|
||||||
incr = data.(int)+1
|
incr = data.(int) + 1
|
||||||
}
|
}
|
||||||
fc.Put(key, incr, FileCacheEmbedExpiry)
|
fc.Put(key, incr, FileCacheEmbedExpiry)
|
||||||
return nil
|
return nil
|
||||||
@ -179,7 +179,7 @@ func (fc *FileCache) Decr(key string) error {
|
|||||||
if reflect.TypeOf(data).Name() != "int" || data.(int)-1 <= 0 {
|
if reflect.TypeOf(data).Name() != "int" || data.(int)-1 <= 0 {
|
||||||
decr = 0
|
decr = 0
|
||||||
} else {
|
} else {
|
||||||
decr = data.(int)-1
|
decr = data.(int) - 1
|
||||||
}
|
}
|
||||||
fc.Put(key, decr, FileCacheEmbedExpiry)
|
fc.Put(key, decr, FileCacheEmbedExpiry)
|
||||||
return nil
|
return nil
|
||||||
|
Loading…
Reference in New Issue
Block a user