42 Commits

Author SHA1 Message Date
antirez
f28d386cc5 Keyspace events: it is now possible to select subclasses of events.
When keyspace events are enabled, the overhead is not sever but
noticeable, so this commit introduces the ability to select subclasses
of events in order to avoid to generate events the user is not
interested in.

The events can be selected using redis.conf or CONFIG SET / GET.
2013-01-28 13:15:12 +01:00
antirez
f2d1105618 Keyspace events added for more commands. 2013-01-28 13:14:56 +01:00
antirez
ccef29ae2c Initial test events for the new keyspace notification API. 2013-01-28 13:14:46 +01:00
antirez
45d02df764 Additionally two typos fixed thanks to @jodal 2013-01-19 13:46:14 +01:00
guiquanz
df7a5b7157 Fixed many typos. 2013-01-19 10:59:44 +01:00
antirez
a32d1ddff6 BSD license added to every C source and header file. 2012-11-08 18:31:32 +01:00
antirez
10f6b3ec22 Invert two sides of if expression in SET to avoid a lookup.
Because of the short circuit behavior of && inverting the two sides of
the if expression avoids an hash table lookup if the non-EX variant of
SET is called.

Thanks to Weibin Yao (@yaoweibin on github) for spotting this.
2012-10-31 09:23:05 +01:00
antirez
c2ca94242c Bit-related string operations moved to bitop.c
All the general string operations are implemented in t_string.c, however
the bit operations, while targeting the string type, are better served
in a specific file where we have the implementations of the following
four commands and helper functions:

    GETBIT
    SETBIT
    BITOP
    BITCOUNT

In the future this file will probably contain more code related to
making the BITOP and BITCOUNT operations faster.
2012-05-24 15:19:51 +02:00
antirez
aa1bc12f39 New commands: BITOP and BITCOUNT.
The motivation for this new commands is to be search in the usage of
Redis for real time statistics. See the article "Fast real time metrics
using Redis".

http://blog.getspool.com/2011/11/29/fast-easy-realtime-metrics-using-redis-bitmaps/

In general Redis strings when used as bitmaps using the SETBIT/GETBIT
command provide a very space-efficient and fast way to store statistics.
For instance in a web application with users, every user can be
associated with a key that shows every day in which the user visited the
web service. This information can be really valuable to extract user
behaviour information.

With Redis bitmaps doing this is very simple just saying that a given
day is 0 (the data the service was put online) and all the next days are
1, 2, 3, and so forth. So with SETBIT it is possible to set the bit
corresponding to the current day every time the user visits the site.

It is possible to take the count of the bit sets on the run, this is
extremely easy using a Lua script. However a fast bit count native
operation can be useful, especially if it can operate on ranges, or when
the string is small like in the case of days (even if you consider many
years it is still extremely little data).

For this reason BITOP was introduced. The command counts the number of
bits set to 1 in a string, with optional range:

BITCOUNT key [start end]

The start/end parameters are similar to GETRANGE. If omitted the whole
string is tested.

Population counting is more useful when bit-level operations like AND,
OR and XOR are avaialble. For instance I can test multiple users to see
the number of days three users visited the site at the same time. To do
this we can take the AND of all the bitmaps, and then count the set bits.

For this reason the BITOP command was introduced:

BITOP [AND|OR|XOR|NOT] dest_key src_key1 src_key2 src_key3 ... src_keyN

In the special case of NOT (that inverts the bits) only one source key
can be passed.

The judicious use of BITCOUNT and BITOP combined can lead to interesting
use cases with very space efficient representation of data.

The implementation provided is still not tested and optimized for speed,
next commits will introduce unit tests. Later the implementation will be
profiled to see if it is possible to gain an important amount of speed
without making the code much more complex.
2012-05-24 15:19:43 +02:00
antirez
adf89d46b7 Fixed undefined behavior in *INCR style functions overflow detection. Sorry clang! 2012-02-21 18:26:11 +01:00
antirez
15e3ed44ab rewrite INCRBYFLOAT as SETs for AOF/replication 2011-11-14 10:15:13 +01:00
antirez
be43c9a854 INCRBYFLOAT implementation 2011-11-12 19:27:35 +01:00
antirez
bd19e43850 high resolution expires API modified to use separated commands. AOF transation to PEXPIREAT of all the expire-style commands fixed. 2011-11-10 17:52:02 +01:00
antirez
027876589d Initial support for key expire times with millisecond resolution. RDB version is now 3, new opcoded added for high resolution times. Redis is still able to correctly load RDB version 2. Tests passing but still a work in progress. API to specify milliseconds expires still missing, but the precision of normal expires is now already improved and working. 2011-11-09 16:51:19 +01:00
antirez
b0ab1f8c76 useless call removed, thanks to Pieter for spotting this 2011-06-20 16:42:37 +02:00
antirez
0b00199553 DB API refactoring. The changes were designed together with Pieter Noordhuis. 2011-06-20 16:42:16 +02:00
antirez
338d6cb3ea Fixed return value of GETRANGE / SUBSTR 2011-03-04 16:22:50 +01:00
antirez
26257371a3 Merge branch 'master' into unstable 2011-01-04 19:07:15 +01:00
antirez
a8d2f3796d touched key for WATCH refactored into a more general thing that can be used also for the cache system. Some more changes towards diskstore working. 2010-12-29 19:39:42 +01:00
Pieter Noordhuis
0c0fda4c83 limits.h is already included from redis.h 2010-12-23 11:14:05 +00:00
antirez
0333e80364 overflow detection in INCR family functions 2010-12-19 12:22:12 +01:00
Pieter Noordhuis
b2b1cfc2aa Use helper function for string object length 2010-12-15 11:49:04 +01:00
Pieter Noordhuis
7e753892ae Use helper functions in APPEND 2010-12-15 11:40:36 +01:00
Pieter Noordhuis
4b232afcf3 Disable negative offsets for SETRANGE 2010-12-15 11:30:50 +01:00
Pieter Noordhuis
77f5cf47e0 Make SETBIT return original bit value 2010-12-15 00:42:32 +01:00
antirez
00058c9f6c removed a test that will never be true fixing the compilation on Linux 2010-12-14 17:46:20 +01:00
Pieter Noordhuis
c247d94dff Refactor and rename SUBSTR to GETRANGE
SUBSTR is renamed to GETRANGE to have better consistency between command
names (with SETRANGE as its dual). GETRANGE is still aliased as SUBSTR.
2010-12-14 15:16:29 +01:00
Pieter Noordhuis
641289670c Add SETRANGE command implementation and tests 2010-12-14 14:20:51 +01:00
Pieter Noordhuis
fae765c340 Don't decode object on STRLEN when not necessary 2010-12-14 10:42:41 +01:00
Pieter Noordhuis
cc8322919a Change function name to match what it does 2010-12-10 12:16:16 +01:00
Pieter Noordhuis
cb33445bcd Typo 2010-12-10 12:06:24 +01:00
Pieter Noordhuis
09586f8b7a Add generic function to grow an sds value
Move logic concerned with setting a bit in an sds to the SETBIT command
instead of keeping it in sds.c. The function to grow an sds can and will
be reused for a command to set a range within a string value.
2010-12-10 11:58:21 +01:00
Pieter Noordhuis
73dbf7c942 Enforce maximum string value length of 512MB 2010-12-09 17:16:10 +01:00
Pieter Noordhuis
c139b6812d Add commands SETBIT/GETBIT 2010-12-09 16:39:33 +01:00
Pieter Noordhuis
000b46faac Convert objects in the command procs instead of the protocol code 2010-10-17 17:21:41 +02:00
Pieter Noordhuis
3ab203762f Use specialized function to add status and error replies 2010-09-02 23:33:06 +02:00
Pieter Noordhuis
b70d355521 Use existing reply functions where possible 2010-09-02 19:52:04 +02:00
Pieter Noordhuis
0537e7bf80 Use specialized function to add multi bulk reply length 2010-09-02 12:51:14 +02:00
antirez
bcf2995c98 support for write operations against expiring keys, by master-controlled expiring in replication and AOF synthesizing DEL operations 2010-08-02 18:13:39 +02:00
antirez
80091bbaac STRLEN command implemented 2010-07-27 10:09:26 +02:00
antirez
5b4bff9c17 WATCH is now affected only when write commands actually modify the key content 2010-07-12 12:01:15 +02:00
antirez
e2641e09cc redis.c split into many different C files.
networking related stuff moved into networking.c

moved more code

more work on layout of source code

SDS instantaneuos memory saving. By Pieter and Salvatore at VMware ;)

cleanly compiling again after the first split, now splitting it in more C files

moving more things around... work in progress

split replication code

splitting more

Sets split

Hash split

replication split

even more splitting

more splitting

minor change
2010-07-01 14:38:51 +02:00