1
0
mirror of https://github.com/astaxie/beego.git synced 2025-07-07 01:30:18 +00:00
cache add function
// IncrBy increase counter by num.
IncrBy(key string, num int)
// DecrBy decrease counter by num.
DecrBy(key string, num int)
This commit is contained in:
hible
2018-07-31 17:19:09 +08:00
parent a09bafbf2a
commit c7c0b01ec5
10 changed files with 284 additions and 1 deletions

View File

@ -58,6 +58,22 @@ func TestMemcacheCache(t *testing.T) {
t.Error("get err")
}
if err = bm.IncrBy("astaxie", 2); err != nil {
t.Error("Incr Error", err)
}
if v, err := strconv.Atoi(string(bm.Get("astaxie").([]byte))); err != nil || v != 4 {
t.Error("get err")
}
if err = bm.DecrBy("astaxie", 2); err != nil {
t.Error("Decr Error", err)
}
if v, err := strconv.Atoi(string(bm.Get("astaxie").([]byte))); err != nil || v != 2 {
t.Error("get err")
}
if err = bm.Decr("astaxie"); err != nil {
t.Error("Decr Error", err)
}
@ -65,6 +81,7 @@ func TestMemcacheCache(t *testing.T) {
if v, err := strconv.Atoi(string(bm.Get("astaxie").([]byte))); err != nil || v != 1 {
t.Error("get err")
}
bm.Delete("astaxie")
if bm.IsExist("astaxie") {
t.Error("delete err")