

Redis: Zero to Master in 30 minutes - latch
http://openmymind.net/2011/11/8/Redis-Zero-To-Master-In-30-Minutes-Part-1/

======
simonw
If you don't already know how to use Redis, it's hard to think of a technology
that offers as good a return on time invested - you really can pick up
everything you need to know about it in a few hours, and once you add it to
your tool kit you'll find no shortage of problems that it can help solve.

~~~
pjscott
Your post got me thinking: what other things can one learn that give
ridiculously good return on time invested? Not just technologies, but
anything. Here's an incomplete list:

* Graph flow: a lot of interesting problems can be solved efficiently by converting them to graph flow problems.

* Basic microeconomics: the world looks different once you understand it, and it's not that hard to learn. A cheap enlightenment boost!

* Monoid-cached trees. Guy Steele explains better than I could. Video and slides:

<http://vimeo.com/6624203>

[http://labs.oracle.com/projects/plrg/Publications/ICFPAugust...](http://labs.oracle.com/projects/plrg/Publications/ICFPAugust2009Steele.pdf)

Any others? I'm sure I haven't done more than scratch the surface.

------
LeafStorm
One complaint: Don't actually use the KEYS command. It's not very efficient.
Instead, keep a set of all the keys you would want to delete. When you call
KEYS, it has to do a linear scan of every key in the database, and since it is
stored as a hash table there really isn't a way to optimize it. It's useful
for inspecting things in redis-cli, but not much else.

~~~
antirez
KEYS is indeed only a debugging command, as clearly stated in the
documentation.

~~~
malkia
Probably it should be named DBG_KEYS or D_KEYS - some evil hard to type name,
that says - I'm to be used very rarely.

But what do I know, just giving friendly advice...

------
antirez
Since this was not posted on HN maybe it is a shameless plug that's worth it:

<http://antirez.com/post/short-term-redis-plans.html>

~~~
wglb
Actually it was: <http://news.ycombinator.com/item?id=3208387>

------
latch
Direct link to part 2: [http://openmymind.net/2011/11/8/Redis-Zero-To-Master-
In-30-M...](http://openmymind.net/2011/11/8/Redis-Zero-To-Master-
In-30-Minutes-Part-2/)

------
antirez
What's wrong with the name 'strings' for Redis strings?

<http://en.wikipedia.org/wiki/String_(computer_science)>

If you change the title of the wikipedia article you can read it as a
description of Redis strings almost verbatim ;)

~~~
latch
edit: I don't really want to get into a CS/data structures argument with you,
'cuz I like having a chance at winning when I argue stuff.

It's not wrong. I think when you say String people think of:

    
    
       String name = "Leto Atreides";
    

In Redis (and I guess as a Computer Science term) it means:

    
    
      byte[] anything = ....
    

Although, the Wiki page does say:

    
    
      generally understood as a data type...using some character encoding
    

With the redis implementation not having any character encoding.

It isn't a big deal, but I think you'd find that it can be a little confusing
to us some.

~~~
antirez
but strings in most languages such as C, Python or Ruby are exactly random
access sequences of bytes. And btw 'binary' is a form of encoding in a string.
So Redis strings are strings ;) in a full sense.

I think that if calling what are strings, "strings", can generate confusion,
go figure how much confusion can be created by calling them with another
term...

~~~
davedx
A byte array is not necessarily a string.

Is an image a string?

Is a video on YouTube a giant string?

They happen to be equivalent at a data storage level, but they're not
semantically equivalent. I think the article explains the difference quite
well to be honest.

------
wildmXranat
Read the source code of <http://lamernews.com> on github
<http://github.com/antirez/lamernews> .It's written by the author of Redis.

------
code_duck
I love that this is so direct, and it's helped me learn more about redis.

Some of the explanations are a bit confusing though. I'm not sure I know what
a List is - though I suspect, knowing JavaScript, Python, and PHP pretty well,
I know what a List is. Descriptions like "If a hash is like a string with an
extra field layer" are just plain confusing. Why not put it in terms of
commonly understood programming languages? The examples are in Ruby, why not
let us know which Ruby structures these most closely correspond to, for
instance?

I do appreciate the particular names in the example text, however so I'm
willing to overlook this.

~~~
latch
You are right. I cleaned up a bit of the garbage and just used a more
straightforward explanation. Thanks.

~~~
code_duck
Thanks for listening to my suggestions! Again, I appreciate the article.

------
davidw
At that rate of learning, you'll surpass antirez in a few days.

~~~
skrebbel
I started last week and compiled a stable Redis 2.8 this morning.

------
quadhome
What is the recommended configuration for in-memory stores like Redis? On a
separate machine than its client application?

If it's all going in memory, why not run the client on that machine and use
native data structures?

~~~
antirez
There are obvious reasons for needing networking access, but even when you
don't need it:

1) Redis is much more memory efficient than your average programming language.
2) Redis handles persistence and replication for you. Not a joke. 3) Accessing
data with atomic operations on complex data types from your application using
multiple threads can create more problems. 4) Your application is free of
doing other stuff if you use a non blocking client, if you are asking Redis to
do computationally intensive tasks. 5) There is no easy way to model Redis
sorted sets, in many very high level languages, at the same speed, without
writing a C extension.

~~~
rarrrrrr
Another benefit I run into is sidestepping the GIL in Python or Ruby. Instead
of using multiple threads to manipulate data in-process, use multiple
processes to manipulate the data in Redis.

------
feralchimp
My first questions about any new dev tool/tech are "Where does it run?" and
"What is the primary interface for working with it?"

So I'd love to see the paragraph that begins "There are various ways to
install Redis" expanded. In particular, what's the workflow between a) I just
downloaded something called Redis, and b) I am issuing commands to learn along
with these examples.

Otherwise very clear and concise. Well done.

~~~
gizzlon
Only used Redis on *nix, but there it's very easy: Just download, unpack and
compile.

No need to install it just to play with it..

Compiles in no time at all =)

------
malkia
I really want to try redis, but Windows is big part of our development. Is
there any port of redis to Windows?

~~~
kds
<https://github.com/dmajkic/redis/downloads>

~~~
malkia
Thanks!

------
jeromeparadis
In part 2, correct me if I'm wrong, but isn't the member you're adding for
jobs a key? Isn't the code to see if it's already a member unnecessary? It
shouldn't add duplicates since the member's value doesn't change (it's a key).
Granted, it's unnecessary to re-add the key to the jobs sorted set as the code
does, but the explanation doesn't seem right. On the other hand, you could
call zadd again to change the score.

~~~
latch
uh..ya, ur right. I'll fix it

~~~
jeromeparadis
I see you fixed it. Cool. By the way, I've been using Redis extensively for a
while and your tutorial is quite good. Congrats!

------
j_baker
Redis is just a good piece of software. I don't see any reason why a web
programmer couldn't benefit from spending time to learn it.

I simply don't think a remotely complex web application can do without it
these days.

