Ejemplo n.º 1
0
// getStrLen returns number the number of bytes of the string
func getStrLen(client *pool.Client, key string) (int, error) {
	reply := client.Cmd("STRLEN", key)
	if reply.Err != nil {
		return -1, reply.Err
	}
	return reply.Int()
}
Ejemplo n.º 2
0
func (redisStore *RedisStore) uidToHorde(client *pool.Client, uid string) (string, error) {
	reply := client.Cmd("GET", uidToHordeKey(uid))
	if reply.Err != nil {
		return "", reply.Err
	}
	if reply.Type == redis.NilReply {
		return "", nil
	}
	hordeName, err := reply.Str()
	if err != nil {
		return "", err
	}
	return hordeName, nil
}
Ejemplo n.º 3
0
// deleteExpire modifies the key so that it is inaccessble via normal methods
// and sets the TTL to a week
func deleteExpire(client *pool.Client, key string) error {
	// Make gob inaccessble using normal key
	reply := client.Cmd("RENAME", key, deletedKey(key))
	if reply.Err != nil {
		return reply.Err
	}
	reply = client.Cmd("EXPIRE", deletedKey(key), DEL_TTL)
	if reply.Err != nil {
		return reply.Err
	}
	if i, _ := reply.Int(); i == 0 {
		gslog.Error("REDIS: could not set expire time for deleted key '%s'", key)
	}
	return nil
}
Ejemplo n.º 4
0
// setTTL sets the expire time for the uid based on the size.  Expects to be
// run in a goroutine, so it does not return an error.  It instead logs it.
// TODO: should I be passing the client in?
func (redisStore *RedisStore) setTTLRoutine(client *pool.Client, gobInfo *storage.GobInfo, data []byte) {
	defer redisStore.Put(client)
	ttl := calculateTTL(data)
	if i, _ := client.Cmd("EXPIRE", gobKey(gobInfo.UID), ttl).Int(); i == 0 {
		gslog.Error("REDIS: could not set expire time for key '%s' to %d seconds", gobKey(gobInfo.UID), ttl)
	}
	if i, _ := client.Cmd("EXPIRE", gobInfoKey(gobInfo.UID), ttl).Int(); i == 0 {
		gslog.Error("REDIS: could not set expire time for key '%s' to %d seconds", gobInfoKey(gobInfo.UID), ttl)
	}
	if i, _ := client.Cmd("EXPIRE", tokenKey(gobInfo.Token), ttl).Int(); i == 0 {
		gslog.Error("REDIS: could not set expire time for key '%s' to %d seconds", tokenKey(gobInfo.Token), ttl)
	}
}