Skip to content

Commit

Permalink
Start every sentence on a new line
Browse files Browse the repository at this point in the history
  • Loading branch information
pietern committed Jun 19, 2012
1 parent 99169cf commit 339e513
Show file tree
Hide file tree
Showing 99 changed files with 922 additions and 745 deletions.
21 changes: 11 additions & 10 deletions commands/append.md
@@ -1,6 +1,7 @@
If `key` already exists and is a string, this command appends the `value` at the
end of the string. If `key` does not exist it is created and set as an empty
string, so `APPEND` will be similar to `SET` in this special case.
end of the string.
If `key` does not exist it is created and set as an empty string, so `APPEND`
will be similar to `SET` in this special case.

@return

Expand All @@ -17,24 +18,24 @@ string, so `APPEND` will be similar to `SET` in this special case.
## Pattern: Time series

the `APPEND` command can be used to create a very compact representation of a
list of fixed-size samples, usually referred as _time series_. Every time a new
sample arrives we can store it using the command
list of fixed-size samples, usually referred as _time series_.
Every time a new sample arrives we can store it using the command

APPEND timeseries "fixed-size sample"

Accessing individual elements in the time series is not hard:

* `STRLEN` can be used in order to obtain the number of samples.
* `GETRANGE` allows for random access of elements. If our time series have an
associated time information we can easily implement a binary search to get
range combining `GETRANGE` with the Lua scripting engine available in Redis
2.6.
* `GETRANGE` allows for random access of elements.
If our time series have an associated time information we can easily implement
a binary search to get range combining `GETRANGE` with the Lua scripting
engine available in Redis 2.6.
* `SETRANGE` can be used to overwrite an existing time serie.

The limitations of this pattern is that we are forced into an append-only mode
of operation, there is no way to cut the time series to a given size easily
because Redis currently lacks a command able to trim string objects. However the
space efficiency of time series stored in this way is remarkable.
because Redis currently lacks a command able to trim string objects.
However the space efficiency of time series stored in this way is remarkable.

Hint: it is possible to switch to a different key based on the current Unix
time, in this way it is possible to have just a relatively small amount of
Expand Down
9 changes: 5 additions & 4 deletions commands/auth.md
@@ -1,10 +1,11 @@
Request for authentication in a password protected Redis server. Redis can be
instructed to require a password before allowing clients to execute commands.
Request for authentication in a password protected Redis server.
Redis can be instructed to require a password before allowing clients to execute
commands.
This is done using the `requirepass` directive in the configuration file.

If `password` matches the password in the configuration file, the server replies
with the `OK` status code and starts accepting commands. Otherwise, an error is
returned and the clients needs to try a new password.
with the `OK` status code and starts accepting commands.
Otherwise, an error is returned and the clients needs to try a new password.

**Note**: because of the high performance nature of Redis, it is possible to try
a lot of passwords in parallel in very short time, so make sure to generate a
Expand Down
16 changes: 10 additions & 6 deletions commands/bgrewriteaof.md
@@ -1,18 +1,22 @@
Instruct Redis to start an [Append Only File][tpaof] rewrite process. The
rewrite will create a small optimized version of the current Append Only File.
Instruct Redis to start an [Append Only File][tpaof] rewrite process.
The rewrite will create a small optimized version of the current Append Only
File.

[tpaof]: /topics/persistence#append-only-file

If `BGREWRITEAOF` fails, no data gets lost as the old AOF will be untouched.

The rewrite will be only triggered by Redis if there is not already a background
process doing persistence. Specifically:
process doing persistence.
Specifically:

* If a Redis child is creating a snapshot on disk, the AOF rewrite is
_scheduled_ but not started until the saving child producing the RDB file
terminates. In this case the `BGREWRITEAOF` will still return an OK code, but
with an appropriate message. You can check if an AOF rewrite is scheduled
looking at the `INFO` command starting from Redis 2.6.
terminates.
In this case the `BGREWRITEAOF` will still return an OK code, but with an
appropriate message.
You can check if an AOF rewrite is scheduled looking at the `INFO` command
starting from Redis 2.6.
* If an AOF rewrite is already in progress the command returns an error and no
AOF rewrite will be scheduled for a later time.

Expand Down
10 changes: 6 additions & 4 deletions commands/bgsave.md
@@ -1,7 +1,9 @@
Save the DB in background. The OK code is immediately returned. Redis forks,
the parent continues to server the clients, the child saves the DB on disk
then exit. A client my be able to check if the operation succeeded using the
`LASTSAVE` command.
Save the DB in background.
The OK code is immediately returned.
Redis forks, the parent continues to server the clients, the child saves the DB
on disk then exit.
A client my be able to check if the operation succeeded using the `LASTSAVE`
command.

Please refer to the [persistence documentation][tp] for detailed information.

Expand Down
25 changes: 14 additions & 11 deletions commands/bitcount.md
@@ -1,8 +1,8 @@
Count the number of set bits (population counting) in a string.

By default all the bytes contained in the string are examined. It is possible
to specify the counting operation only in an interval passing the additional
arguments _start_ and _end_.
By default all the bytes contained in the string are examined.
It is possible to specify the counting operation only in an interval passing the
additional arguments _start_ and _end_.

Like for the `GETRANGE` command start and end can contain negative values in
order to index bytes starting from the end of the string, where -1 is the last
Expand All @@ -27,13 +27,15 @@ The number of bits set to 1.
## Pattern: real time metrics using bitmaps

Bitmaps are a very space efficient representation of certain kinds of
information. One example is a web application that needs the history of user
visits, so that for instance it is possible to determine what users are good
targets of beta features, or for any other purpose.
information.
One example is a web application that needs the history of user visits, so that
for instance it is possible to determine what users are good targets of beta
features, or for any other purpose.

Using the `SETBIT` command this is trivial to accomplish, identifying every
day with a small progressive integer. For instance day 0 is the first day the
application was put online, day 1 the next day, and so forth.
Using the `SETBIT` command this is trivial to accomplish, identifying every day
with a small progressive integer.
For instance day 0 is the first day the application was put online, day 1 the
next day, and so forth.

Every time an user performs a page view, the application can register that in
the current day the user visited the web site using the `SETBIT` command setting
Expand All @@ -52,8 +54,9 @@ bitmaps][hbgc212fermurb]".

In the above example of counting days, even after 10 years the application is
online we still have just `365*10` bits of data per user, that is just 456 bytes
per user. With this amount of data `BITCOUNT` is still as fast as any other O(1)
Redis command like `GET` or `INCR`.
per user.
With this amount of data `BITCOUNT` is still as fast as any other O(1) Redis
command like `GET` or `INCR`.

When the bitmap is big, there are two alternatives:

Expand Down
9 changes: 5 additions & 4 deletions commands/bitop.md
Expand Up @@ -41,8 +41,9 @@ size of the longest input string.
## Pattern: real time metrics using bitmaps

`BITOP` is a good complement to the pattern documented in the `BITCOUNT` command
documentation. Different bitmaps can be combined in order to obtain a target
bitmap where to perform the population counting operation.
documentation.
Different bitmaps can be combined in order to obtain a target bitmap where to
perform the population counting operation.

See the article called "[Fast easy realtime metrics using Redis
bitmaps][hbgc212fermurb]" for an interesting use cases.
Expand All @@ -51,8 +52,8 @@ bitmaps][hbgc212fermurb]" for an interesting use cases.

## Performance considerations

`BITOP` is a potentially slow command as it runs in O(N) time. Care should be
taken when running it against long input strings.
`BITOP` is a potentially slow command as it runs in O(N) time.
Care should be taken when running it against long input strings.

For real time metrics and statistics involving large inputs a good approach is
to use a slave (with read-only option disabled) where to perform the bit-wise
Expand Down
51 changes: 28 additions & 23 deletions commands/blpop.md
@@ -1,17 +1,19 @@
`BLPOP` is a blocking list pop primitive. It is the blocking version of `LPOP`
because it blocks the connection when there are no elements to pop from any of
the given lists. An element is popped from the head of the first list that is
non-empty, with the given keys being checked in the order that they are given.
`BLPOP` is a blocking list pop primitive.
It is the blocking version of `LPOP` because it blocks the connection when there
are no elements to pop from any of the given lists.
An element is popped from the head of the first list that is non-empty, with the
given keys being checked in the order that they are given.

## Non-blocking behavior

When `BLPOP` is called, if at least one of the specified keys contain a
non-empty list, an element is popped from the head of the list and returned to
the caller together with the `key` it was popped from.

Keys are checked in the order that they are given. Let's say that the key
`list1` doesn't exist and `list2` and `list3` hold non-empty lists. Consider the
following command:
Keys are checked in the order that they are given.
Let's say that the key `list1` doesn't exist and `list2` and `list3` hold
non-empty lists.
Consider the following command:

BLPOP list1 list2 list3 0

Expand All @@ -32,27 +34,29 @@ the client will unblock returning a `nil` multi-bulk value when the specified
timeout has expired without a push operation against at least one of the
specified keys.

The timeout argument is interpreted as an integer value. A timeout of zero can
be used to block indefinitely.
The timeout argument is interpreted as an integer value.
A timeout of zero can be used to block indefinitely.

## Multiple clients blocking for the same keys

Multiple clients can block for the same key. They are put into a queue, so the
first to be served will be the one that started to wait earlier, in a first-
`!BLPOP` first-served fashion.
Multiple clients can block for the same key.
They are put into a queue, so the first to be served will be the one that
started to wait earlier, in a first- `!BLPOP` first-served fashion.

## `!BLPOP` inside a `!MULTI` / `!EXEC` transaction

`BLPOP` can be used with pipelining (sending multiple commands and reading the
replies in batch), but it does not make sense to use `BLPOP` inside a `MULTI` /
`EXEC` block. This would require blocking the entire server in order to execute
the block atomically, which in turn does not allow other clients to perform a
push operation.
`EXEC` block.
This would require blocking the entire server in order to execute the block
atomically, which in turn does not allow other clients to perform a push
operation.

The behavior of `BLPOP` inside `MULTI` / `EXEC` when the list is empty is to
return a `nil` multi-bulk reply, which is the same thing that happens when
the timeout is reached. If you like science fiction, think of time flowing at
infinite speed inside a `MULTI` / `EXEC` block.
return a `nil` multi-bulk reply, which is the same thing that happens when the
timeout is reached.
If you like science fiction, think of time flowing at infinite speed inside a
`MULTI` / `EXEC` block.

@return

Expand All @@ -76,11 +80,12 @@ infinite speed inside a `MULTI` / `EXEC` block.
## Pattern: Event notification

Using blocking list operations it is possible to mount different blocking
primitives. For instance for some application you may need to block waiting for
elements into a Redis Set, so that as far as a new element is added to the Set,
it is possible to retrieve it without resort to polling. This would require
a blocking version of `SPOP` that is not available, but using blocking list
operations we can easily accomplish this task.
primitives.
For instance for some application you may need to block waiting for elements
into a Redis Set, so that as far as a new element is added to the Set, it is
possible to retrieve it without resort to polling.
This would require a blocking version of `SPOP` that is not available, but using
blocking list operations we can easily accomplish this task.

The consumer will do:

Expand Down
9 changes: 5 additions & 4 deletions commands/brpop.md
@@ -1,7 +1,8 @@
`BRPOP` is a blocking list pop primitive. It is the blocking version of `RPOP`
because it blocks the connection when there are no elements to pop from any of
the given lists. An element is popped from the tail of the first list that is
non-empty, with the given keys being checked in the order that they are given.
`BRPOP` is a blocking list pop primitive.
It is the blocking version of `RPOP` because it blocks the connection when there
are no elements to pop from any of the given lists.
An element is popped from the tail of the first list that is non-empty, with the
given keys being checked in the order that they are given.

See the [BLPOP documentation][cb] for the exact semantics, since `BRPOP` is
identical to `BLPOP` with the only difference being that it pops elements from
Expand Down
9 changes: 5 additions & 4 deletions commands/brpoplpush.md
@@ -1,7 +1,8 @@
`BRPOPLPUSH` is the blocking variant of `RPOPLPUSH`. When `source` contains
elements, this command behaves exactly like `RPOPLPUSH`. When `source` is empty,
Redis will block the connection until another client pushes to it or until
`timeout` is reached. A `timeout` of zero can be used to block indefinitely.
`BRPOPLPUSH` is the blocking variant of `RPOPLPUSH`.
When `source` contains elements, this command behaves exactly like `RPOPLPUSH`.
When `source` is empty, Redis will block the connection until another client
pushes to it or until `timeout` is reached.
A `timeout` of zero can be used to block indefinitely.

See `RPOPLPUSH` for more information.

Expand Down
17 changes: 9 additions & 8 deletions commands/config get.md
@@ -1,14 +1,15 @@
The `CONFIG GET` command is used to read the configuration parameters of a
running Redis server. Not all the configuration parameters are supported in
Redis 2.4, while Redis 2.6 can read the whole configuration of a server using
this command.
running Redis server.
Not all the configuration parameters are supported in Redis 2.4, while Redis 2.6
can read the whole configuration of a server using this command.

The symmetric command used to alter the configuration at run time is `CONFIG
SET`.

`CONFIG GET` takes a single argument, that is glob style pattern. All the
configuration parameters matching this parameter are reported as a list of
key-value pairs. Example:
`CONFIG GET` takes a single argument, that is glob style pattern.
All the configuration parameters matching this parameter are reported as a list
of key-value pairs.
Example:

redis> config get *max-*-entries*
1) "hash-max-zipmap-entries"
Expand All @@ -31,8 +32,8 @@ following important differences:
the `redis.conf` abbreviated form (10k 2gb ... and so forth), everything
should be specified as a well formed 64 bit integer, in the base unit of the
configuration directive.
* The save parameter is a single string of space separated integers. Every pair
of integers represent a seconds/modifications threshold.
* The save parameter is a single string of space separated integers.
Every pair of integers represent a seconds/modifications threshold.

For instance what in `redis.conf` looks like:

Expand Down
17 changes: 9 additions & 8 deletions commands/config set.md
@@ -1,6 +1,7 @@
The `CONFIG SET` command is used in order to reconfigure the server at run time
without the need to restart Redis. You can change both trivial parameters or
switch from one to another persistence option using this command.
without the need to restart Redis.
You can change both trivial parameters or switch from one to another persistence
option using this command.

The list of configuration parameters supported by `CONFIG SET` can be obtained
issuing a `CONFIG GET *` command, that is the symmetrical command used to obtain
Expand All @@ -20,8 +21,8 @@ following important differences:
the `redis.conf` abbreviated form (10k 2gb ... and so forth), everything
should be specified as a well formed 64 bit integer, in the base unit of the
configuration directive.
* The save parameter is a single string of space separated integers. Every pair
of integers represent a seconds/modifications threshold.
* The save parameter is a single string of space separated integers.
Every pair of integers represent a seconds/modifications threshold.

For instance what in `redis.conf` looks like:

Expand All @@ -33,8 +34,8 @@ and after 300 seconds if there are at least 10 changes to the datasets, should
be set using `CONFIG SET` as "900 1 300 10".

It is possible to switch persistence from RDB snapshotting to append only file
(and the other way around) using the `CONFIG SET` command. For more information
about how to do that please check [persistence page][tp].
(and the other way around) using the `CONFIG SET` command.
For more information about how to do that please check [persistence page][tp].

[tp]: /topics/persistence

Expand All @@ -49,5 +50,5 @@ options are not mutually exclusive.

@return

@status-reply: `OK` when the configuration was set properly. Otherwise an error
is returned.
@status-reply: `OK` when the configuration was set properly.
Otherwise an error is returned.
4 changes: 2 additions & 2 deletions commands/debug object.md
@@ -1,4 +1,4 @@
`DEBUG OBJECT` is a debugging command that should not be used by clients. Check
the `OBJECT` command instead.
`DEBUG OBJECT` is a debugging command that should not be used by clients.
Check the `OBJECT` command instead.

@status-reply
4 changes: 2 additions & 2 deletions commands/debug segfault.md
@@ -1,4 +1,4 @@
`DEBUG SEGFAULT` performs an invalid memory access that crashes Redis. It is
used to simulate bugs during the development.
`DEBUG SEGFAULT` performs an invalid memory access that crashes Redis.
It is used to simulate bugs during the development.

@status-reply
9 changes: 5 additions & 4 deletions commands/decr.md
@@ -1,7 +1,8 @@
Decrements the number stored at `key` by one. If the key does not exist, it
is set to `0` before performing the operation. An error is returned if the
key contains a value of the wrong type or contains a string that can not be
represented as integer. This operation is limited to **64 bit signed integers**.
Decrements the number stored at `key` by one.
If the key does not exist, it is set to `0` before performing the operation.
An error is returned if the key contains a value of the wrong type or contains a
string that can not be represented as integer.
This operation is limited to **64 bit signed integers**.

See `INCR` for extra information on increment/decrement operations.

Expand Down
9 changes: 5 additions & 4 deletions commands/decrby.md
@@ -1,7 +1,8 @@
Decrements the number stored at `key` by `decrement`. If the key does not exist,
it is set to `0` before performing the operation. An error is returned if the
key contains a value of the wrong type or contains a string that can not be
represented as integer. This operation is limited to 64 bit signed integers.
Decrements the number stored at `key` by `decrement`.
If the key does not exist, it is set to `0` before performing the operation.
An error is returned if the key contains a value of the wrong type or contains a
string that can not be represented as integer.
This operation is limited to 64 bit signed integers.

See `INCR` for extra information on increment/decrement operations.

Expand Down

0 comments on commit 339e513

Please sign in to comment.