Skip to content
Browse files

Keeping 50 items needs to use ltrim 0 49, not ltrim 0 50.

- Typo, wording in Lists and in Sets.
  • Loading branch information...
1 parent 4dea2ba commit ca4188c78e694abe248662312ccb183d61c189a1 @FGM FGM committed
Showing with 5 additions and 5 deletions.
  1. +5 −5 en/redis.md
View
10 en/redis.md
@@ -96,7 +96,7 @@ Using specific data structures for specific problems? Isn't that how we code? Yo
Redis has the same basic concept of a database that you are already familiar with. A database contains a set of data. The typical use-case for a database is to group all of an application's data together and to keep it separate from another application's.
-In Redis, databases are simply identified by a number with the default database being number `0`. If you want to change to a different database you can do so via the `select` command. In the command line interface, type `select 1`. Redis should reply with an `OK` message and your prompt should change to something like `redis 127.0.0.1:6379[1]>`. If you want to switch back to the default database, just enter `select 0` in the command line interface..
+In Redis, databases are simply identified by a number with the default database being number `0`. If you want to change to a different database you can do so via the `select` command. In the command line interface, type `select 1`. Redis should reply with an `OK` message and your prompt should change to something like `redis 127.0.0.1:6379[1]>`. If you want to switch back to the default database, just enter `select 0` in the command line interface.
## Commands, Keys and Values
@@ -237,7 +237,7 @@ Looking at hashes from the perspective of a well-defined object, such as a user,
Lists let you store and manipulate an array of values for a given key. You can add values to the list, get the first or last value and manipulate values at a given index. Lists maintain their order and have efficient index-based operations. We could have a `newusers` list which tracks the newest registered users to our site:
lpush newusers goku
- ltrim newusers 0 50
+ ltrim newusers 0 49
First we push a new user at the front of the list, then we trim it so that it only contains the last 50 users. This is a common pattern. `ltrim` is an O(N) operation, where N is the number of values we are removing. In this case, where we always trim after a single insert, it'll actually have a constant performance of O(1) (because N will always be equal to 1).
@@ -248,11 +248,11 @@ This is also the first time that we are seeing a value in one key referencing a
The above is a bit of Ruby which shows the type of multiple roundtrips we talked about before.
-Of course, lists aren't only good for storing references to other keys. The values can be anything. You could use lists to store logs or track the path a user is taking through a site. If you were building a game, you might use it to track a queued user actions.
+Of course, lists aren't only good for storing references to other keys. The values can be anything. You could use lists to store logs or track the path a user is taking through a site. If you were building a game, you might use one to track a queued user actions.
## Sets
-Set are used to store unique values and provide a number of set-based operations, like unions. Sets aren't ordered but they provide efficient value-based operations. A friend's list is the classic example of using a set:
+Sets are used to store unique values and provide a number of set-based operations, like unions. Sets aren't ordered but they provide efficient value-based operations. A friend's list is the classic example of using a set:
sadd friends:leto ghanima paul chani jessica
sadd friends:duncan paul jessica alia
@@ -262,7 +262,7 @@ Regardless of how many friends a user has, we can efficiently tell (O(1)) whethe
sismember friends:leto jessica
sismember friends:leto vladimir
-Furthermore we can see what two or more people share the same friends:
+Furthermore we can see whether two or more people share the same friends:
sinter friends:leto friends:duncan

0 comments on commit ca4188c

Please sign in to comment.
Something went wrong with that request. Please try again.