FAQ
I have a doubt..

How i make a sort in this dataset.

@r.sadd('teste', {:order => 1, :desc => "um"})
@r.sadd('teste', {:order => 2, :desc => "dois"})

I need orby by order.

Thanks

--
You received this message because you are subscribed to the Google Groups "Redis DB" group.
To post to this group, send email to redis-db@googlegroups.com.
To unsubscribe from this group, send email to redis-db+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/redis-db?hl=en.

Search Discussions

  • Josiah Carlson at Mar 6, 2012 at 5:03 pm
    You can't do that with sets the way you have it. If each of your items
    has an id, you could do something else...

    Given data like:

    {:order => 1, :desc => "um", :id => 4}
    {:order => 2, :desc => "dois", :id => 3}


    You could perform:
    @r.sadd('sortable', 4)
    @r.hmset('data:4', {:order => 1, :desc => "um", :id => 4})
    @r.sadd('sortable', 3)
    @r.hmset('data:3', {:order => 2, :desc => "dois", :id => 3})

    Then to sort by your order:
    @r.sort('sortable', {:by => 'data:*->order'})


    There are other methods using zsets, which may or may not be better
    for your problem.

    Regards,
    - Josiah
    On Tue, Mar 6, 2012 at 5:10 AM, Markd2lp wrote:
    I have a doubt..

    How i make a sort in this dataset.

    @r.sadd('teste', {:order => 1, :desc => "um"})
    @r.sadd('teste', {:order => 2, :desc => "dois"})

    I need orby by order.

    Thanks

    --
    You received this message because you are subscribed to the Google Groups "Redis DB" group.
    To post to this group, send email to redis-db@googlegroups.com.
    To unsubscribe from this group, send email to redis-db+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/redis-db?hl=en.
    --
    You received this message because you are subscribed to the Google Groups "Redis DB" group.
    To post to this group, send email to redis-db@googlegroups.com.
    To unsubscribe from this group, send email to redis-db+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/redis-db?hl=en.
  • Markd2lp at Mar 6, 2012 at 5:38 pm
    Thanks for your help

    Att
    Marcos

    Em 6 de março de 2012 14:02, Josiah Carlson <josiah.carlson@gmail.com>escreveu:
    You can't do that with sets the way you have it. If each of your items
    has an id, you could do something else...

    Given data like:

    {:order => 1, :desc => "um", :id => 4}
    {:order => 2, :desc => "dois", :id => 3}


    You could perform:
    @r.sadd('sortable', 4)
    @r.hmset('data:4', {:order => 1, :desc => "um", :id => 4})
    @r.sadd('sortable', 3)
    @r.hmset('data:3', {:order => 2, :desc => "dois", :id => 3})

    Then to sort by your order:
    @r.sort('sortable', {:by => 'data:*->order'})


    There are other methods using zsets, which may or may not be better
    for your problem.

    Regards,
    - Josiah
    On Tue, Mar 6, 2012 at 5:10 AM, Markd2lp wrote:
    I have a doubt..

    How i make a sort in this dataset.

    @r.sadd('teste', {:order => 1, :desc => "um"})
    @r.sadd('teste', {:order => 2, :desc => "dois"})

    I need orby by order.

    Thanks

    --
    You received this message because you are subscribed to the Google
    Groups "Redis DB" group.
    To post to this group, send email to redis-db@googlegroups.com.
    To unsubscribe from this group, send email to
    redis-db+unsubscribe@googlegroups.com.
    For more options, visit this group at
    http://groups.google.com/group/redis-db?hl=en.
    --
    You received this message because you are subscribed to the Google Groups
    "Redis DB" group.
    To post to this group, send email to redis-db@googlegroups.com.
    To unsubscribe from this group, send email to
    redis-db+unsubscribe@googlegroups.com.
    For more options, visit this group at
    http://groups.google.com/group/redis-db?hl=en.
    --
    You received this message because you are subscribed to the Google Groups "Redis DB" group.
    To post to this group, send email to redis-db@googlegroups.com.
    To unsubscribe from this group, send email to redis-db+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/redis-db?hl=en.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupredis-db @
categoriesredis
postedMar 6, '12 at 1:29p
activeMar 6, '12 at 5:38p
posts3
users2
websiteredis.io
irc#redis

2 users in discussion

Markd2lp: 2 posts Josiah Carlson: 1 post

People

Translate

site design / logo © 2017 Grokbase