xref: /redis-3.2.3/README.md (revision bba53d7f)
1c414db2fSantirezThis README is just a fast *quick start* document. You can find more detailed documentation at http://redis.io.
2cac9a900Santirez
3f916a589SantirezWhat is Redis?
4f916a589Santirez--------------
5f916a589Santirez
63ff49affSJan-Erik RedigerRedis is often referred as a *data structures* server. What this means is that Redis provides access to mutable data structures via a set of commands, which are sent using a *server-client* model with TCP sockets and a simple protocol. So different processes can query and modify the same data structures in a shared way.
7f916a589Santirez
8f916a589SantirezData structures implemented into Redis have a few special properties:
9f916a589Santirez
10f916a589Santirez* Redis cares to store them on disk, even if they are always served and modified into the server memory. This means that Redis is fast, but that is also non-volatile.
11f916a589Santirez* Implementation of data structures stress on memory efficiency, so data structures inside Redis will likely use less memory compared to the same data structure modeled using an high level programming language.
123ff49affSJan-Erik Rediger* Redis offers a number of features that are natural to find in a database, like replication, tunable levels of durability, cluster, high availability.
13f916a589Santirez
14fb532881SJan-Erik RedigerAnother good example is to think of Redis as a more complex version of memcached, where the operations are not just SETs and GETs, but operations to work with complex data types like Lists, Sets, ordered data structures, and so forth.
15f916a589Santirez
16f916a589SantirezIf you want to know more, this is a list of selected starting points:
17f916a589Santirez
189795ad1bSantirez* Introduction to Redis data types. http://redis.io/topics/data-types-intro
199795ad1bSantirez* Try Redis directly inside your browser. http://try.redis.io
209795ad1bSantirez* The full list of Redis commands. http://redis.io/commands
219795ad1bSantirez* There is much more inside the Redis official documentation. http://redis.io/documentation
22f916a589Santirez
23cac9a900SantirezBuilding Redis
24cac9a900Santirez--------------
25cac9a900Santirez
26cac9a900SantirezRedis can be compiled and used on Linux, OSX, OpenBSD, NetBSD, FreeBSD.
27cac9a900SantirezWe support big endian and little endian architectures, and both 32 bit
28cac9a900Santirezand 64 bit systems.
29cac9a900Santirez
30cac9a900SantirezIt may compile on Solaris derived systems (for instance SmartOS) but our
31c414db2fSantirezsupport for this platform is *best effort* and Redis is not guaranteed to
322576864bSJan-Erik Redigerwork as well as in Linux, OSX, and \*BSD there.
33cac9a900Santirez
34cac9a900SantirezIt is as simple as:
35cac9a900Santirez
36cac9a900Santirez    % make
37cac9a900Santirez
38cac9a900SantirezYou can run a 32 bit Redis binary using:
39cac9a900Santirez
40cac9a900Santirez    % make 32bit
41cac9a900Santirez
42cac9a900SantirezAfter building Redis is a good idea to test it, using:
43cac9a900Santirez
44cac9a900Santirez    % make test
45cac9a900Santirez
46cac9a900SantirezFixing build problems with dependencies or cached build options
472576864bSJan-Erik Rediger---------
482576864bSJan-Erik Rediger
49cac9a900SantirezRedis has some dependencies which are included into the `deps` directory.
50cac9a900Santirez`make` does not rebuild dependencies automatically, even if something in the
51*bba53d7fSSeth Bergmansource code of dependencies is changed.
52cac9a900Santirez
53cac9a900SantirezWhen you update the source code with `git pull` or when code inside the
54cac9a900Santirezdependencies tree is modified in any other way, make sure to use the following
55cac9a900Santirezcommand in order to really clean everything and rebuild from scratch:
56cac9a900Santirez
57cac9a900Santirez    make distclean
58cac9a900Santirez
59cac9a900SantirezThis will clean: jemalloc, lua, hiredis, linenoise.
60cac9a900Santirez
61cac9a900SantirezAlso if you force certain build options like 32bit target, no C compiler
62cac9a900Santirezoptimizations (for debugging purposes), and other similar build time options,
632576864bSJan-Erik Redigerthose options are cached indefinitely until you issue a `make distclean`
64cac9a900Santirezcommand.
65cac9a900Santirez
66cac9a900SantirezFixing problems building 32 bit binaries
67cac9a900Santirez---------
68cac9a900Santirez
69cac9a900SantirezIf after building Redis with a 32 bit target you need to rebuild it
70cac9a900Santirezwith a 64 bit target, or the other way around, you need to perform a
712576864bSJan-Erik Rediger`make distclean` in the root directory of the Redis distribution.
72cac9a900Santirez
73cac9a900SantirezIn case of build errors when trying to build a 32 bit binary of Redis, try
74cac9a900Santirezthe following steps:
75cac9a900Santirez
76cac9a900Santirez* Install the packages libc6-dev-i386 (also try g++-multilib).
772576864bSJan-Erik Rediger* Try using the following command line instead of `make 32bit`:
782576864bSJan-Erik Rediger  `make CFLAGS="-m32 -march=native" LDFLAGS="-m32"`
79cac9a900Santirez
80cac9a900SantirezAllocator
81cac9a900Santirez---------
82cac9a900Santirez
83cac9a900SantirezSelecting a non-default memory allocator when building Redis is done by setting
84cac9a900Santirezthe `MALLOC` environment variable. Redis is compiled and linked against libc
85cac9a900Santirezmalloc by default, with the exception of jemalloc being the default on Linux
86cac9a900Santirezsystems. This default was picked because jemalloc has proven to have fewer
87cac9a900Santirezfragmentation problems than libc malloc.
88cac9a900Santirez
89cac9a900SantirezTo force compiling against libc malloc, use:
90cac9a900Santirez
91cac9a900Santirez    % make MALLOC=libc
92cac9a900Santirez
93cac9a900SantirezTo compile against jemalloc on Mac OS X systems, use:
94cac9a900Santirez
95cac9a900Santirez    % make MALLOC=jemalloc
96cac9a900Santirez
97cac9a900SantirezVerbose build
98cac9a900Santirez-------------
99cac9a900Santirez
100cac9a900SantirezRedis will build with a user friendly colorized output by default.
101cac9a900SantirezIf you want to see a more verbose output use the following:
102cac9a900Santirez
103cac9a900Santirez    % make V=1
104cac9a900Santirez
105cac9a900SantirezRunning Redis
106cac9a900Santirez-------------
107cac9a900Santirez
108cac9a900SantirezTo run Redis with the default configuration just type:
109cac9a900Santirez
110cac9a900Santirez    % cd src
111cac9a900Santirez    % ./redis-server
112cac9a900Santirez
113cac9a900SantirezIf you want to provide your redis.conf, you have to run it using an additional
114cac9a900Santirezparameter (the path of the configuration file):
115cac9a900Santirez
116cac9a900Santirez    % cd src
117cac9a900Santirez    % ./redis-server /path/to/redis.conf
118cac9a900Santirez
119cac9a900SantirezIt is possible to alter the Redis configuration passing parameters directly
120cac9a900Santirezas options using the command line. Examples:
121cac9a900Santirez
122cac9a900Santirez    % ./redis-server --port 9999 --slaveof 127.0.0.1 6379
123cac9a900Santirez    % ./redis-server /etc/redis/6379.conf --loglevel debug
124cac9a900Santirez
125cac9a900SantirezAll the options in redis.conf are also supported as options using the command
126cac9a900Santirezline, with exactly the same name.
127cac9a900Santirez
128cac9a900SantirezPlaying with Redis
129cac9a900Santirez------------------
130cac9a900Santirez
131cac9a900SantirezYou can use redis-cli to play with Redis. Start a redis-server instance,
132cac9a900Santirezthen in another terminal try the following:
133cac9a900Santirez
134cac9a900Santirez    % cd src
135cac9a900Santirez    % ./redis-cli
136cac9a900Santirez    redis> ping
137cac9a900Santirez    PONG
138cac9a900Santirez    redis> set foo bar
139cac9a900Santirez    OK
140cac9a900Santirez    redis> get foo
141cac9a900Santirez    "bar"
142cac9a900Santirez    redis> incr mycounter
143cac9a900Santirez    (integer) 1
144cac9a900Santirez    redis> incr mycounter
145cac9a900Santirez    (integer) 2
146cac9a900Santirez    redis>
147cac9a900Santirez
148cac9a900SantirezYou can find the list of all the available commands at http://redis.io/commands.
149cac9a900Santirez
150cac9a900SantirezInstalling Redis
151cac9a900Santirez-----------------
152cac9a900Santirez
153cac9a900SantirezIn order to install Redis binaries into /usr/local/bin just use:
154cac9a900Santirez
155cac9a900Santirez    % make install
156cac9a900Santirez
157cac9a900SantirezYou can use `make PREFIX=/some/other/directory install` if you wish to use a
158cac9a900Santirezdifferent destination.
159cac9a900Santirez
160cac9a900SantirezMake install will just install binaries in your system, but will not configure
161cac9a900Santirezinit scripts and configuration files in the appropriate place. This is not
162cac9a900Santirezneeded if you want just to play a bit with Redis, but if you are installing
163cac9a900Santirezit the proper way for a production system, we have a script doing this
164cac9a900Santirezfor Ubuntu and Debian systems:
165cac9a900Santirez
166cac9a900Santirez    % cd utils
167cac9a900Santirez    % ./install_server.sh
168cac9a900Santirez
169cac9a900SantirezThe script will ask you a few questions and will setup everything you need
170cac9a900Santirezto run Redis properly as a background daemon that will start again on
171cac9a900Santirezsystem reboots.
172cac9a900Santirez
173cac9a900SantirezYou'll be able to stop and start Redis using the script named
174cac9a900Santirez`/etc/init.d/redis_<portnumber>`, for instance `/etc/init.d/redis_6379`.
175cac9a900Santirez
176cac9a900SantirezCode contributions
177cac9a900Santirez---
178cac9a900Santirez
179cac9a900SantirezNote: by contributing code to the Redis project in any form, including sending
180cac9a900Santireza pull request via Github, a code fragment or patch via private email or
181cac9a900Santirezpublic discussion groups, you agree to release your code under the terms
18207a89654SJan-Erik Redigerof the BSD license that you can find in the [COPYING][1] file included in the Redis
183cac9a900Santirezsource distribution.
184cac9a900Santirez
18507a89654SJan-Erik RedigerPlease see the [CONTRIBUTING][2] file in this source distribution for more
186cac9a900Santirezinformation.
187cac9a900Santirez
188cac9a900SantirezEnjoy!
18907a89654SJan-Erik Rediger
19007a89654SJan-Erik Rediger[1]: https://github.com/antirez/redis/blob/unstable/COPYING
19107a89654SJan-Erik Rediger[2]: https://github.com/antirez/redis/blob/unstable/CONTRIBUTING
192