mirror of
https://github.com/astaxie/beego.git
synced 2025-06-13 11:50:39 +00:00
Revert "hible"
This commit is contained in:
30
cache/memcache/memcache.go
vendored
30
cache/memcache/memcache.go
vendored
@ -127,21 +127,6 @@ func (rc *Cache) Incr(key string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// IncrBy increase counter by num.
|
||||
func (rc *Cache) IncrBy(key string, num int) error {
|
||||
if num < 1 {
|
||||
return errors.New("increase num should be a positive number")
|
||||
}
|
||||
|
||||
if rc.conn == nil {
|
||||
if err := rc.connectInit(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
_, err := rc.conn.Increment(key, uint64(num))
|
||||
return err
|
||||
}
|
||||
|
||||
// Decr decrease counter.
|
||||
func (rc *Cache) Decr(key string) error {
|
||||
if rc.conn == nil {
|
||||
@ -153,21 +138,6 @@ func (rc *Cache) Decr(key string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// DecrBy decrease counter by num.
|
||||
func (rc *Cache) DecrBy(key string, num int) error {
|
||||
if num < 1 {
|
||||
return errors.New("decrease num should be a positive number")
|
||||
}
|
||||
|
||||
if rc.conn == nil {
|
||||
if err := rc.connectInit(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
_, err := rc.conn.Decrement(key, uint64(num))
|
||||
return err
|
||||
}
|
||||
|
||||
// IsExist check value exists in memcache.
|
||||
func (rc *Cache) IsExist(key string) bool {
|
||||
if rc.conn == nil {
|
||||
|
17
cache/memcache/memcache_test.go
vendored
17
cache/memcache/memcache_test.go
vendored
@ -58,22 +58,6 @@ 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)
|
||||
}
|
||||
@ -81,7 +65,6 @@ 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")
|
||||
|
Reference in New Issue
Block a user