Example #1
0
File: redis.go Project: kanbl/beego
// check cache exist in redis.
func (rc *RedisCache) IsExist(key string) bool {
	v, err := redis.Bool(rc.do("HEXISTS", rc.key, key))
	if err != nil {
		return false
	}

	return v
}
Example #2
0
File: redis.go Project: 4eek/beego
// check cache's existence in redis.
func (rc *RedisCache) IsExist(key string) bool {
	v, err := redis.Bool(rc.do("EXISTS", key))
	if err != nil {
		return false
	}
	if v == false {
		_, err := rc.do("HDEL", rc.key, key)
		if err != nil {
			return false
		}
	}
	return v
}
Example #3
0
func (rc *RedisCache) Decr(key string) error {
	if rc.c == nil {
		var err error
		rc.c, err = rc.connectInit()
		if err != nil {
			return err
		}
	}
	_, err := redis.Bool(rc.c.Do("HINCRBY", rc.key, key, -1))
	if err != nil {
		return err
	}
	return nil
}
Example #4
0
func (rc *RedisCache) IsExist(key string) bool {
	if rc.c == nil {
		var err error
		rc.c, err = rc.connectInit()
		if err != nil {
			return false
		}
	}
	v, err := redis.Bool(rc.c.Do("HEXISTS", rc.key, key))
	if err != nil {
		return false
	}
	return v
}
Example #5
0
File: redis.go Project: kanbl/beego
// decrease counter in redis.
func (rc *RedisCache) Decr(key string) error {
	_, err := redis.Bool(rc.do("HINCRBY", rc.key, key, -1))
	return err
}
Example #6
0
File: redis.go Project: 4eek/beego
// increase counter in redis.
func (rc *RedisCache) Incr(key string) error {
	_, err := redis.Bool(rc.do("INCRBY", key, 1))
	return err
}