Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LRange not working when using ring.Ring client? #378

Closed
didip opened this issue Sep 28, 2016 · 2 comments
Closed

LRange not working when using ring.Ring client? #378

didip opened this issue Sep 28, 2016 · 2 comments

Comments

@didip
Copy link

didip commented Sep 28, 2016

I cannot seemed to be able to get anything from LRange().

The use-case looks like this:

redisClient := redis.NewRing(&redis.RingOptions{
    Addrs: map[string]string{"shard0": "localhost:6379"},
})

key := "abc_test|5m|1475024400|aaa.bbb"

// Set
redisClient.RPush(key, 1)
redisClient.RPush(key, 2)

// I then opened redis-cli and checked that there are 2 values.

// Get all of them
result, err := redisClient.LRange(key, 0, -1).Result()
// err is nil and I get empty slice.

// Curiously, I created a simple Redis client and still get empty result.
simple := redis.NewClient(&redis.Options{
    Addr: "localhost:6379",
})
result, err := simple.LRange(key, 0, -1).Result() // Still empty.

It's a fairly straight forward usage. I must be missing something here.

Systems Environment

  • OS X El Capitan
  • Go 1.7.1
  • Redis server v=3.0.5 64bit
  • Library: gopkg.in/redis.v4, Revision: bb84d84
@vmihailenco
Copy link
Collaborator

It works as expected for me on Redis 3.2.0

package main

import (
    "fmt"

    redis "gopkg.in/redis.v4"
)

func main() {
    redisClient := redis.NewRing(&redis.RingOptions{
        Addrs: map[string]string{"shard0": "localhost:6379"},
    })

    key := "abc_test|5m|1475024400|aaa.bbb"

    // Set
    redisClient.RPush(key, 1)
    redisClient.RPush(key, 2)

    // I then opened redis-cli and checked that there are 2 values.

    // Get all of them
    result, err := redisClient.LRange(key, 0, -1).Result()
    fmt.Println(result, err)
}
go run main.go
[1 2 1 2] <nil>

@didip
Copy link
Author

didip commented Sep 29, 2016

I am really sorry for wasting your time, it turns out to be bug on my code.

I misread the unix-timestamp portion of the key. Creation used UTC and deletion used local time.

Actual create and deletes work as expected.

@didip didip closed this as completed Sep 29, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants