[redis-db] How to document redis scheme?

684 views
Skip to first unread message

jason.桂林

unread,
May 14, 2012, 1:34:45 PM5/14/12
to redi...@googlegroups.com
Hi guys, I have a very simple question, how to document redis scheme?


--
Best regards,

桂林 (Gui Lin)

guileen@twitter

Salvatore Sanfilippo

unread,
May 14, 2012, 1:41:03 PM5/14/12
to redi...@googlegroups.com
Good question Gui,

what about creating an informal standard in this thread that we can
eventually put in the redis.io documentation?

There are a number of approaches, one may be descriptive:

Set followers:<user_id> {
<follower_id>, <follower_id>, ...
}

The other can instead reason in terms of Redis commands. Like
Description / commands:

Every user has a key representing his followers:
SADD followers:<user_id> <follower_id_1> <follower_id_2>

IMHO we should describe how to document a single key like the above,
and additional we should provide some kind of skeleton about the
sections a good schema documentation should have.

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



--
Salvatore 'antirez' Sanfilippo
open source developer - VMware
http://invece.org

Beauty is more important in computing than anywhere else in technology
because software is so complicated. Beauty is the ultimate defence
against complexity.
-- David Gelernter

Fritzy

unread,
May 14, 2012, 1:46:52 PM5/14/12
to redi...@googlegroups.com

Gui Lin,

There are usually two things that you want to document: the key schema and the execution order of a given method.
If you're using Lua scripts, the method can be documented as the Lua script itself, otherwise a bit of psuedocode is in order:

# Adding An Item

WATCH items.{item_group_id}
Multi:
  LPUSH items.{item_group_id} item_id
  HSET items.values.{item_group_id} item_id item_value
Exec: (on failure, retry)
  PUBLISH items.feed.new {"group": item_group_id, "item_id": item_id, "item_value": item_value}

For layout, I tend to think of things in terms of an instance of an object with a keytag, and the documentation there-of is all of the keys that a given object instance may have.

# Item Group keys

LIST items.{item_group_id} // publish ordered list of item ids
HSET items.values.{item_group_id} // value storage
.. etc.

There are many ways you could document it, but that is what I've been doing.

--Nathan Fritz

Eric Pickup

unread,
May 14, 2012, 8:03:22 PM5/14/12
to redi...@googlegroups.com

We "cheated" for hashes and used SQL-like create table statements (minus the "create table" bit) with a new "optional" keyword.  It gives the hash name, field name and the expected contents.  In hindsight, since all hashes map to objects in our code, could probably have used object notation but we created our hashes before our objects and were converting from SQL so it seemed easiest/best.


For lists and sets we kept it simple with entries like:
Sorted Set: videos:sort_filter:release_date {epoch_time} {video_id}
Sorted Set: videos:sort_filter:rating {rating_float} {video_id}
List: job:queue {serialized_job_object}

 

It is short and obvious in most cases.  We haven't started playing with Lua so that simplifies things.  When we do, things might need to change.


Eric Pickup

YouPorn Lead Developer

Manwin Canada

Office: +1.514.359.3555

Fax: +1.514.359.3556

Twitter: EricPickupYP

 


From: redi...@googlegroups.com [redi...@googlegroups.com] on behalf of Fritzy [natha...@gmail.com]
Sent: Monday, May 14, 2012 1:46 PM
To: redi...@googlegroups.com
Subject: Re: [redis-db] How to document redis scheme?

--
You received this message because you are subscribed to the Google Groups "Redis DB" group.
To view this discussion on the web visit https://groups.google.com/d/msg/redis-db/-/uZMgFnyEcUIJ.

To post to this group, send email to redi...@googlegroups.com.
To unsubscribe from this group, send email to redis-db+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/redis-db?hl=en.
This e-mail may be privileged and/or confidential, and the sender does not waive any related rights and obligations. Any distribution, use or copying of this e-mail or the information it contains by other than an intended recipient is unauthorized. If you received this e-mail in error, please advise me (by return e-mail or otherwise) immediately. Ce courrier électronique est confidentiel et protégé. L'expéditeur ne renonce pas aux droits et obligations qui s'y rapportent. Toute diffusion, utilisation ou copie de ce message ou des renseignements qu'il contient par une personne autre que le (les) destinataire(s) désigné(s) est interdite. Si vous recevez ce courrier électronique par erreur, veuillez m'en aviser immédiatement, par retour de courrier électronique ou par un autre moyen.

jason.桂林

unread,
May 15, 2012, 2:30:01 AM5/15/12
to redi...@googlegroups.com
Cool

2012/5/15 Eric Pickup <Eric....@manwin.com>

martin mauchauffée

unread,
May 15, 2012, 8:59:39 AM5/15/12
to redi...@googlegroups.com
We put the records in different groups and we write something like that:

case:CASE:node:NODE (string)

    Store in a JSON object all properties for each nodes of each cases.

    CASE is the index of the case.
    NODE is the index of the node.

    TTL: Persistent

Jirka Pinkas

unread,
Jun 14, 2013, 6:20:34 AM6/14/13
to redi...@googlegroups.com
I ended up writing my own application focused on documenting redis database:


I hope this helps someone.

Jirka Pinkas
Reply all
Reply to author
Forward
0 new messages