redis-server 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +38 -0
- data/README.md +33 -0
- data/bin/redis +114 -0
- data/redis/Makefile +5 -0
- data/redis/extconf.rb +3 -0
- data/redis/redis-2.2.11/00-RELEASENOTES +199 -0
- data/redis/redis-2.2.11/BUGS +1 -0
- data/redis/redis-2.2.11/CONTRIBUTING +13 -0
- data/redis/redis-2.2.11/COPYING +10 -0
- data/redis/redis-2.2.11/Changelog +1032 -0
- data/redis/redis-2.2.11/INSTALL +30 -0
- data/redis/redis-2.2.11/Makefile +22 -0
- data/redis/redis-2.2.11/README +83 -0
- data/redis/redis-2.2.11/TODO +4 -0
- data/redis/redis-2.2.11/client-libraries/README +11 -0
- data/redis/redis-2.2.11/deps/hiredis/COPYING +10 -0
- data/redis/redis-2.2.11/deps/hiredis/Makefile +115 -0
- data/redis/redis-2.2.11/deps/hiredis/README.md +311 -0
- data/redis/redis-2.2.11/deps/hiredis/TODO +2 -0
- data/redis/redis-2.2.11/deps/hiredis/adapters/ae.h +95 -0
- data/redis/redis-2.2.11/deps/hiredis/adapters/libev.h +113 -0
- data/redis/redis-2.2.11/deps/hiredis/adapters/libevent.h +76 -0
- data/redis/redis-2.2.11/deps/hiredis/async.c +321 -0
- data/redis/redis-2.2.11/deps/hiredis/async.h +112 -0
- data/redis/redis-2.2.11/deps/hiredis/example-ae.c +53 -0
- data/redis/redis-2.2.11/deps/hiredis/example-libev.c +47 -0
- data/redis/redis-2.2.11/deps/hiredis/example-libevent.c +48 -0
- data/redis/redis-2.2.11/deps/hiredis/example.c +67 -0
- data/redis/redis-2.2.11/deps/hiredis/fmacros.h +15 -0
- data/redis/redis-2.2.11/deps/hiredis/hiredis.c +1058 -0
- data/redis/redis-2.2.11/deps/hiredis/hiredis.h +170 -0
- data/redis/redis-2.2.11/deps/hiredis/net.c +170 -0
- data/redis/redis-2.2.11/deps/hiredis/net.h +43 -0
- data/redis/redis-2.2.11/deps/hiredis/sds.c +479 -0
- data/redis/redis-2.2.11/deps/hiredis/sds.h +77 -0
- data/redis/redis-2.2.11/deps/hiredis/test.c +479 -0
- data/redis/redis-2.2.11/deps/hiredis/util.h +40 -0
- data/redis/redis-2.2.11/deps/linenoise/Makefile +10 -0
- data/redis/redis-2.2.11/deps/linenoise/README.markdown +45 -0
- data/redis/redis-2.2.11/deps/linenoise/example.c +27 -0
- data/redis/redis-2.2.11/deps/linenoise/linenoise.c +609 -0
- data/redis/redis-2.2.11/deps/linenoise/linenoise.h +55 -0
- data/redis/redis-2.2.11/design-documents/REDIS-CLUSTER +214 -0
- data/redis/redis-2.2.11/design-documents/REDIS-CLUSTER-2 +343 -0
- data/redis/redis-2.2.11/doc/AppendCommand.html +48 -0
- data/redis/redis-2.2.11/doc/AppendOnlyFileHowto.html +41 -0
- data/redis/redis-2.2.11/doc/AuthCommand.html +39 -0
- data/redis/redis-2.2.11/doc/Benchmarks.html +129 -0
- data/redis/redis-2.2.11/doc/BgrewriteaofCommand.html +41 -0
- data/redis/redis-2.2.11/doc/BgsaveCommand.html +39 -0
- data/redis/redis-2.2.11/doc/BlpopCommand.html +51 -0
- data/redis/redis-2.2.11/doc/BrpoplpushCommand.html +39 -0
- data/redis/redis-2.2.11/doc/CommandReference.html +47 -0
- data/redis/redis-2.2.11/doc/Comparisons.html +42 -0
- data/redis/redis-2.2.11/doc/ConfigCommand.html +76 -0
- data/redis/redis-2.2.11/doc/Configuration.html +38 -0
- data/redis/redis-2.2.11/doc/ConnectionHandlingSidebar.html +36 -0
- data/redis/redis-2.2.11/doc/ControlCommandsSidebar.html +36 -0
- data/redis/redis-2.2.11/doc/Credits.html +38 -0
- data/redis/redis-2.2.11/doc/DbsizeCommand.html +38 -0
- data/redis/redis-2.2.11/doc/DelCommand.html +41 -0
- data/redis/redis-2.2.11/doc/DesignPatterns.html +37 -0
- data/redis/redis-2.2.11/doc/EventLibray.html +44 -0
- data/redis/redis-2.2.11/doc/ExistsCommand.html +42 -0
- data/redis/redis-2.2.11/doc/ExpireCommand.html +96 -0
- data/redis/redis-2.2.11/doc/FAQ.html +70 -0
- data/redis/redis-2.2.11/doc/Features.html +38 -0
- data/redis/redis-2.2.11/doc/FlushallCommand.html +39 -0
- data/redis/redis-2.2.11/doc/FlushdbCommand.html +39 -0
- data/redis/redis-2.2.11/doc/FromSqlToDataStructures.html +37 -0
- data/redis/redis-2.2.11/doc/GenericCommandsSidebar.html +36 -0
- data/redis/redis-2.2.11/doc/GetCommand.html +39 -0
- data/redis/redis-2.2.11/doc/GetbitCommand.html +39 -0
- data/redis/redis-2.2.11/doc/GetsetCommand.html +38 -0
- data/redis/redis-2.2.11/doc/HackingStrings.html +83 -0
- data/redis/redis-2.2.11/doc/HashCommandsSidebar.html +36 -0
- data/redis/redis-2.2.11/doc/Hashes.html +37 -0
- data/redis/redis-2.2.11/doc/HdelCommand.html +39 -0
- data/redis/redis-2.2.11/doc/HexistsCommand.html +39 -0
- data/redis/redis-2.2.11/doc/HgetCommand.html +39 -0
- data/redis/redis-2.2.11/doc/HgetallCommand.html +40 -0
- data/redis/redis-2.2.11/doc/HincrbyCommand.html +45 -0
- data/redis/redis-2.2.11/doc/HlenCommand.html +38 -0
- data/redis/redis-2.2.11/doc/HmgetCommand.html +40 -0
- data/redis/redis-2.2.11/doc/HmsetCommand.html +40 -0
- data/redis/redis-2.2.11/doc/HsetCommand.html +40 -0
- data/redis/redis-2.2.11/doc/HsetnxCommand.html +41 -0
- data/redis/redis-2.2.11/doc/IncrCommand.html +43 -0
- data/redis/redis-2.2.11/doc/InfoCommand.html +48 -0
- data/redis/redis-2.2.11/doc/IntroductionToRedisDataTypes.html +152 -0
- data/redis/redis-2.2.11/doc/KeysCommand.html +43 -0
- data/redis/redis-2.2.11/doc/LastsaveCommand.html +39 -0
- data/redis/redis-2.2.11/doc/LindexCommand.html +40 -0
- data/redis/redis-2.2.11/doc/ListCommandsSidebar.html +36 -0
- data/redis/redis-2.2.11/doc/Lists.html +42 -0
- data/redis/redis-2.2.11/doc/LlenCommand.html +41 -0
- data/redis/redis-2.2.11/doc/LpopCommand.html +41 -0
- data/redis/redis-2.2.11/doc/LrangeCommand.html +47 -0
- data/redis/redis-2.2.11/doc/LremCommand.html +41 -0
- data/redis/redis-2.2.11/doc/LsetCommand.html +38 -0
- data/redis/redis-2.2.11/doc/LtrimCommand.html +47 -0
- data/redis/redis-2.2.11/doc/MgetCommand.html +52 -0
- data/redis/redis-2.2.11/doc/MonitorCommand.html +63 -0
- data/redis/redis-2.2.11/doc/MoveCommand.html +42 -0
- data/redis/redis-2.2.11/doc/MsetCommand.html +44 -0
- data/redis/redis-2.2.11/doc/MultiExecCommand.html +166 -0
- data/redis/redis-2.2.11/doc/NonexistentCommands.html +51 -0
- data/redis/redis-2.2.11/doc/ObjectHashMappers.html +39 -0
- data/redis/redis-2.2.11/doc/Pipelining.html +36 -0
- data/redis/redis-2.2.11/doc/ProgrammingExamples.html +38 -0
- data/redis/redis-2.2.11/doc/ProtocolSpecification.html +137 -0
- data/redis/redis-2.2.11/doc/PublishSubscribe.html +115 -0
- data/redis/redis-2.2.11/doc/QuickStart.html +68 -0
- data/redis/redis-2.2.11/doc/QuitCommand.html +38 -0
- data/redis/redis-2.2.11/doc/README.html +119 -0
- data/redis/redis-2.2.11/doc/RandomkeyCommand.html +39 -0
- data/redis/redis-2.2.11/doc/Redis0100ChangeLog.html +67 -0
- data/redis/redis-2.2.11/doc/Redis0900ChangeLog.html +56 -0
- data/redis/redis-2.2.11/doc/RedisBigData.html +61 -0
- data/redis/redis-2.2.11/doc/RedisCLI.html +37 -0
- data/redis/redis-2.2.11/doc/RedisEventLibrary.html +70 -0
- data/redis/redis-2.2.11/doc/RedisGuides.html +37 -0
- data/redis/redis-2.2.11/doc/RedisInternals.html +38 -0
- data/redis/redis-2.2.11/doc/RedisPipelining.html +93 -0
- data/redis/redis-2.2.11/doc/RedisStatus.html +56 -0
- data/redis/redis-2.2.11/doc/Redis_1_2_0_Changelog.html +40 -0
- data/redis/redis-2.2.11/doc/Redis_2_0_0_Changelog.html +62 -0
- data/redis/redis-2.2.11/doc/Redis_2_0_Whats_new.html +59 -0
- data/redis/redis-2.2.11/doc/RenameCommand.html +39 -0
- data/redis/redis-2.2.11/doc/RenamenxCommand.html +42 -0
- data/redis/redis-2.2.11/doc/ReplicationHowto.html +43 -0
- data/redis/redis-2.2.11/doc/ReplyTypes.html +42 -0
- data/redis/redis-2.2.11/doc/RoadMap.html +38 -0
- data/redis/redis-2.2.11/doc/RpoplpushCommand.html +44 -0
- data/redis/redis-2.2.11/doc/RpushCommand.html +40 -0
- data/redis/redis-2.2.11/doc/SaddCommand.html +41 -0
- data/redis/redis-2.2.11/doc/SaveCommand.html +39 -0
- data/redis/redis-2.2.11/doc/ScardCommand.html +41 -0
- data/redis/redis-2.2.11/doc/SdiffCommand.html +45 -0
- data/redis/redis-2.2.11/doc/SdiffstoreCommand.html +38 -0
- data/redis/redis-2.2.11/doc/SelectCommand.html +39 -0
- data/redis/redis-2.2.11/doc/SetCommand.html +39 -0
- data/redis/redis-2.2.11/doc/SetCommandsSidebar.html +36 -0
- data/redis/redis-2.2.11/doc/SetbitCommand.html +45 -0
- data/redis/redis-2.2.11/doc/SetexCommand.html +42 -0
- data/redis/redis-2.2.11/doc/SetnxCommand.html +51 -0
- data/redis/redis-2.2.11/doc/SetrangeCommand.html +58 -0
- data/redis/redis-2.2.11/doc/Sets.html +36 -0
- data/redis/redis-2.2.11/doc/ShutdownCommand.html +39 -0
- data/redis/redis-2.2.11/doc/SideBar.html +36 -0
- data/redis/redis-2.2.11/doc/SinterCommand.html +40 -0
- data/redis/redis-2.2.11/doc/SinterstoreCommand.html +39 -0
- data/redis/redis-2.2.11/doc/SismemberCommand.html +42 -0
- data/redis/redis-2.2.11/doc/SlaveofCommand.html +41 -0
- data/redis/redis-2.2.11/doc/SmembersCommand.html +38 -0
- data/redis/redis-2.2.11/doc/SmoveCommand.html +44 -0
- data/redis/redis-2.2.11/doc/SortCommand.html +75 -0
- data/redis/redis-2.2.11/doc/SortedSetCommandsSidebar.html +36 -0
- data/redis/redis-2.2.11/doc/SortedSets.html +36 -0
- data/redis/redis-2.2.11/doc/Speed.html +38 -0
- data/redis/redis-2.2.11/doc/SponsorshipHistory.html +38 -0
- data/redis/redis-2.2.11/doc/SpopCommand.html +40 -0
- data/redis/redis-2.2.11/doc/SrandmemberCommand.html +40 -0
- data/redis/redis-2.2.11/doc/SremCommand.html +42 -0
- data/redis/redis-2.2.11/doc/StringCommandsSidebar.html +36 -0
- data/redis/redis-2.2.11/doc/Strings.html +37 -0
- data/redis/redis-2.2.11/doc/StrlenCommand.html +39 -0
- data/redis/redis-2.2.11/doc/SubstrCommand.html +52 -0
- data/redis/redis-2.2.11/doc/SunionCommand.html +40 -0
- data/redis/redis-2.2.11/doc/SunionstoreCommand.html +38 -0
- data/redis/redis-2.2.11/doc/SupportedLanguages.html +60 -0
- data/redis/redis-2.2.11/doc/SupportedPlatforms.html +37 -0
- data/redis/redis-2.2.11/doc/TemplateCommand.html +38 -0
- data/redis/redis-2.2.11/doc/TtlCommand.html +38 -0
- data/redis/redis-2.2.11/doc/TwitterAlikeExample.html +250 -0
- data/redis/redis-2.2.11/doc/TypeCommand.html +46 -0
- data/redis/redis-2.2.11/doc/UnstableSource.html +39 -0
- data/redis/redis-2.2.11/doc/VirtualMemorySpecification.html +156 -0
- data/redis/redis-2.2.11/doc/VirtualMemoryUserGuide.html +66 -0
- data/redis/redis-2.2.11/doc/ZaddCommand.html +43 -0
- data/redis/redis-2.2.11/doc/ZcardCommand.html +41 -0
- data/redis/redis-2.2.11/doc/ZincrbyCommand.html +42 -0
- data/redis/redis-2.2.11/doc/ZrangeCommand.html +42 -0
- data/redis/redis-2.2.11/doc/ZrangebyscoreCommand.html +77 -0
- data/redis/redis-2.2.11/doc/ZrankCommand.html +43 -0
- data/redis/redis-2.2.11/doc/ZremCommand.html +42 -0
- data/redis/redis-2.2.11/doc/ZremrangebyrankCommand.html +39 -0
- data/redis/redis-2.2.11/doc/ZremrangebyscoreCommand.html +39 -0
- data/redis/redis-2.2.11/doc/ZscoreCommand.html +41 -0
- data/redis/redis-2.2.11/doc/ZunionCommand.html +42 -0
- data/redis/redis-2.2.11/doc/ZunionstoreCommand.html +43 -0
- data/redis/redis-2.2.11/doc/index.html +43 -0
- data/redis/redis-2.2.11/doc/redis.png +0 -0
- data/redis/redis-2.2.11/doc/style.css +25 -0
- data/redis/redis-2.2.11/redis.conf +417 -0
- data/redis/redis-2.2.11/src/Makefile +177 -0
- data/redis/redis-2.2.11/src/adlist.c +325 -0
- data/redis/redis-2.2.11/src/adlist.h +92 -0
- data/redis/redis-2.2.11/src/ae.c +390 -0
- data/redis/redis-2.2.11/src/ae.h +117 -0
- data/redis/redis-2.2.11/src/ae_epoll.c +91 -0
- data/redis/redis-2.2.11/src/ae_kqueue.c +93 -0
- data/redis/redis-2.2.11/src/ae_select.c +72 -0
- data/redis/redis-2.2.11/src/anet.c +347 -0
- data/redis/redis-2.2.11/src/anet.h +57 -0
- data/redis/redis-2.2.11/src/aof.c +675 -0
- data/redis/redis-2.2.11/src/config.c +627 -0
- data/redis/redis-2.2.11/src/config.h +64 -0
- data/redis/redis-2.2.11/src/db.c +543 -0
- data/redis/redis-2.2.11/src/debug.c +314 -0
- data/redis/redis-2.2.11/src/dict.c +721 -0
- data/redis/redis-2.2.11/src/dict.h +156 -0
- data/redis/redis-2.2.11/src/fmacros.h +15 -0
- data/redis/redis-2.2.11/src/help.h +638 -0
- data/redis/redis-2.2.11/src/intset.c +422 -0
- data/redis/redis-2.2.11/src/intset.h +19 -0
- data/redis/redis-2.2.11/src/lzf.h +100 -0
- data/redis/redis-2.2.11/src/lzfP.h +159 -0
- data/redis/redis-2.2.11/src/lzf_c.c +295 -0
- data/redis/redis-2.2.11/src/lzf_d.c +150 -0
- data/redis/redis-2.2.11/src/mkreleasehdr.sh +9 -0
- data/redis/redis-2.2.11/src/multi.c +268 -0
- data/redis/redis-2.2.11/src/networking.c +899 -0
- data/redis/redis-2.2.11/src/object.c +484 -0
- data/redis/redis-2.2.11/src/pqsort.c +197 -0
- data/redis/redis-2.2.11/src/pqsort.h +15 -0
- data/redis/redis-2.2.11/src/pubsub.c +267 -0
- data/redis/redis-2.2.11/src/rdb.c +1020 -0
- data/redis/redis-2.2.11/src/redis-benchmark.c +530 -0
- data/redis/redis-2.2.11/src/redis-check-aof.c +185 -0
- data/redis/redis-2.2.11/src/redis-check-dump.c +681 -0
- data/redis/redis-2.2.11/src/redis-cli.c +773 -0
- data/redis/redis-2.2.11/src/redis.c +1677 -0
- data/redis/redis-2.2.11/src/redis.h +1022 -0
- data/redis/redis-2.2.11/src/release.c +13 -0
- data/redis/redis-2.2.11/src/replication.c +557 -0
- data/redis/redis-2.2.11/src/sds.c +639 -0
- data/redis/redis-2.2.11/src/sds.h +78 -0
- data/redis/redis-2.2.11/src/sha1.c +276 -0
- data/redis/redis-2.2.11/src/sha1.h +17 -0
- data/redis/redis-2.2.11/src/solarisfixes.h +22 -0
- data/redis/redis-2.2.11/src/sort.c +389 -0
- data/redis/redis-2.2.11/src/syncio.c +154 -0
- data/redis/redis-2.2.11/src/t_hash.c +476 -0
- data/redis/redis-2.2.11/src/t_list.c +986 -0
- data/redis/redis-2.2.11/src/t_set.c +610 -0
- data/redis/redis-2.2.11/src/t_string.c +438 -0
- data/redis/redis-2.2.11/src/t_zset.c +1084 -0
- data/redis/redis-2.2.11/src/testhelp.h +54 -0
- data/redis/redis-2.2.11/src/util.c +243 -0
- data/redis/redis-2.2.11/src/valgrind.sup +5 -0
- data/redis/redis-2.2.11/src/version.h +1 -0
- data/redis/redis-2.2.11/src/vm.c +1149 -0
- data/redis/redis-2.2.11/src/ziplist.c +1323 -0
- data/redis/redis-2.2.11/src/ziplist.h +15 -0
- data/redis/redis-2.2.11/src/zipmap.c +455 -0
- data/redis/redis-2.2.11/src/zipmap.h +48 -0
- data/redis/redis-2.2.11/src/zmalloc.c +278 -0
- data/redis/redis-2.2.11/src/zmalloc.h +47 -0
- data/redis/redis-2.2.11/tests/assets/default.conf +308 -0
- data/redis/redis-2.2.11/tests/integration/aof.tcl +104 -0
- data/redis/redis-2.2.11/tests/integration/redis-cli.tcl +208 -0
- data/redis/redis-2.2.11/tests/integration/replication.tcl +98 -0
- data/redis/redis-2.2.11/tests/support/redis.tcl +241 -0
- data/redis/redis-2.2.11/tests/support/server.tcl +294 -0
- data/redis/redis-2.2.11/tests/support/test.tcl +190 -0
- data/redis/redis-2.2.11/tests/support/tmpfile.tcl +15 -0
- data/redis/redis-2.2.11/tests/support/util.tcl +296 -0
- data/redis/redis-2.2.11/tests/test_helper.tcl +221 -0
- data/redis/redis-2.2.11/tests/unit/auth.tcl +15 -0
- data/redis/redis-2.2.11/tests/unit/basic.tcl +616 -0
- data/redis/redis-2.2.11/tests/unit/cas.tcl +135 -0
- data/redis/redis-2.2.11/tests/unit/expire.tcl +74 -0
- data/redis/redis-2.2.11/tests/unit/other.tcl +240 -0
- data/redis/redis-2.2.11/tests/unit/printver.tcl +6 -0
- data/redis/redis-2.2.11/tests/unit/protocol.tcl +62 -0
- data/redis/redis-2.2.11/tests/unit/pubsub.tcl +195 -0
- data/redis/redis-2.2.11/tests/unit/quit.tcl +40 -0
- data/redis/redis-2.2.11/tests/unit/sort.tcl +189 -0
- data/redis/redis-2.2.11/tests/unit/type/hash.tcl +300 -0
- data/redis/redis-2.2.11/tests/unit/type/list.tcl +819 -0
- data/redis/redis-2.2.11/tests/unit/type/set.tcl +334 -0
- data/redis/redis-2.2.11/tests/unit/type/zset.tcl +587 -0
- data/redis/redis-2.2.11/utils/build-static-symbols.tcl +22 -0
- data/redis/redis-2.2.11/utils/generate-command-help.rb +112 -0
- data/redis/redis-2.2.11/utils/mktarball.sh +13 -0
- data/redis/redis-2.2.11/utils/redis-copy.rb +78 -0
- data/redis/redis-2.2.11/utils/redis-sha1.rb +52 -0
- data/redis/redis-2.2.11/utils/redis_init_script +42 -0
- metadata +362 -0
@@ -0,0 +1,42 @@
|
|
1
|
+
|
2
|
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<link type="text/css" rel="stylesheet" href="style.css" />
|
6
|
+
</head>
|
7
|
+
<body>
|
8
|
+
<div id="page">
|
9
|
+
|
10
|
+
<div id='header'>
|
11
|
+
<a href="index.html">
|
12
|
+
<img style="border:none" alt="Redis Documentation" src="redis.png">
|
13
|
+
</a>
|
14
|
+
</div>
|
15
|
+
|
16
|
+
<div id="pagecontent">
|
17
|
+
<div class="index">
|
18
|
+
<!-- This is a (PRE) block. Make sure it's left aligned or your toc title will be off. -->
|
19
|
+
<b>MoveCommand: Contents</b><br> <a href="#MOVE _key_ _dbindex_">MOVE _key_ _dbindex_</a><br> <a href="#Return value">Return value</a>
|
20
|
+
</div>
|
21
|
+
|
22
|
+
<h1 class="wikiname">MoveCommand</h1>
|
23
|
+
|
24
|
+
<div class="summary">
|
25
|
+
|
26
|
+
</div>
|
27
|
+
|
28
|
+
<div class="narrow">
|
29
|
+
#sidebar <a href="GenericCommandsSidebar.html">GenericCommandsSidebar</a><h1><a name="MOVE _key_ _dbindex_">MOVE _key_ _dbindex_</a></h1>
|
30
|
+
<blockquote>Move the specified key from the currently selected DB to the specifieddestination DB. Note that this command returns 1 only if the key wassuccessfully moved, and 0 if the target key was already there or if thesource key was not found at all, so it is possible to use MOVE as a lockingprimitive.</blockquote>
|
31
|
+
<h2><a name="Return value">Return value</a></h2><a href="ReplyTypes.html">Integer reply</a>, specifically:<br/><br/><pre class="codeblock python" name="code">
|
32
|
+
1 if the key was moved
|
33
|
+
0 if the key was not moved because already present on the target DB or was not found in the current DB.
|
34
|
+
</pre>
|
35
|
+
|
36
|
+
</div>
|
37
|
+
|
38
|
+
</div>
|
39
|
+
</div>
|
40
|
+
</body>
|
41
|
+
</html>
|
42
|
+
|
@@ -0,0 +1,44 @@
|
|
1
|
+
|
2
|
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<link type="text/css" rel="stylesheet" href="style.css" />
|
6
|
+
</head>
|
7
|
+
<body>
|
8
|
+
<div id="page">
|
9
|
+
|
10
|
+
<div id='header'>
|
11
|
+
<a href="index.html">
|
12
|
+
<img style="border:none" alt="Redis Documentation" src="redis.png">
|
13
|
+
</a>
|
14
|
+
</div>
|
15
|
+
|
16
|
+
<div id="pagecontent">
|
17
|
+
<div class="index">
|
18
|
+
<!-- This is a (PRE) block. Make sure it's left aligned or your toc title will be off. -->
|
19
|
+
<b>MsetCommand: Contents</b><br> <a href="#MSET _key1_ _value1_ _key2_ _value2_ ... _keyN_ _valueN_ (Redis >">MSET _key1_ _value1_ _key2_ _value2_ ... _keyN_ _valueN_ (Redis ></a><br> <a href="#MSETNX _key1_ _value1_ _key2_ _value2_ ... _keyN_ _valueN_ (Redis >">MSETNX _key1_ _value1_ _key2_ _value2_ ... _keyN_ _valueN_ (Redis ></a><br> <a href="#MSET Return value">MSET Return value</a><br> <a href="#MSETNX Return value">MSETNX Return value</a>
|
20
|
+
</div>
|
21
|
+
|
22
|
+
<h1 class="wikiname">MsetCommand</h1>
|
23
|
+
|
24
|
+
<div class="summary">
|
25
|
+
|
26
|
+
</div>
|
27
|
+
|
28
|
+
<div class="narrow">
|
29
|
+
#sidebar <a href="StringCommandsSidebar.html">StringCommandsSidebar</a><h1><a name="MSET _key1_ _value1_ _key2_ _value2_ ... _keyN_ _valueN_ (Redis >">MSET _key1_ _value1_ _key2_ _value2_ ... _keyN_ _valueN_ (Redis ></a></h1> 1.1) =
|
30
|
+
<h1><a name="MSETNX _key1_ _value1_ _key2_ _value2_ ... _keyN_ _valueN_ (Redis >">MSETNX _key1_ _value1_ _key2_ _value2_ ... _keyN_ _valueN_ (Redis ></a></h1> 1.1) =
|
31
|
+
<i>Time complexity: O(1) to set every key</i><blockquote>Set the the respective keys to the respective values. MSET will replace oldvalues with new values, while MSETNX will not perform any operation at alleven if just a single key already exists.</blockquote>
|
32
|
+
<blockquote>Because of this semantic MSETNX can be used in order to set different keysrepresenting different fields of an unique logic object in a way thatensures that either all the fields or none at all are set.</blockquote>
|
33
|
+
<blockquote>Both MSET and MSETNX are atomic operations. This means that for instanceif the keys A and B are modified, another client talking to Redis can eithersee the changes to both A and B at once, or no modification at all.</blockquote>
|
34
|
+
<h2><a name="MSET Return value">MSET Return value</a></h2><a href="ReplyTypes.html">Status code reply</a> Basically +OK as MSET can't fail<h2><a name="MSETNX Return value">MSETNX Return value</a></h2><a href="ReplyTypes.html">Integer reply</a>, specifically:<br/><br/><pre class="codeblock python" name="code">
|
35
|
+
1 if the all the keys were set
|
36
|
+
0 if no key was set (at least one key already existed)
|
37
|
+
</pre>
|
38
|
+
</div>
|
39
|
+
|
40
|
+
</div>
|
41
|
+
</div>
|
42
|
+
</body>
|
43
|
+
</html>
|
44
|
+
|
@@ -0,0 +1,166 @@
|
|
1
|
+
|
2
|
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<link type="text/css" rel="stylesheet" href="style.css" />
|
6
|
+
</head>
|
7
|
+
<body>
|
8
|
+
<div id="page">
|
9
|
+
|
10
|
+
<div id='header'>
|
11
|
+
<a href="index.html">
|
12
|
+
<img style="border:none" alt="Redis Documentation" src="redis.png">
|
13
|
+
</a>
|
14
|
+
</div>
|
15
|
+
|
16
|
+
<div id="pagecontent">
|
17
|
+
<div class="index">
|
18
|
+
<!-- This is a (PRE) block. Make sure it's left aligned or your toc title will be off. -->
|
19
|
+
<b>MultiExecCommand: Contents</b><br> <a href="#WATCH key1 key2 ... keyN (Redis >">WATCH key1 key2 ... keyN (Redis ></a><br> <a href="#UNWATCH">UNWATCH</a><br> <a href="#MULTI">MULTI</a><br> <a href="#COMMAND_1 ...">COMMAND_1 ...</a><br> <a href="#COMMAND_2 ...">COMMAND_2 ...</a><br> <a href="#COMMAND_N ...">COMMAND_N ...</a><br> <a href="#EXEC or DISCARD">EXEC or DISCARD</a><br> <a href="#Usage">Usage</a><br> <a href="#The DISCARD command">The DISCARD command</a><br> <a href="#Check and Set (CAS) transactions using WATCH">Check and Set (CAS) transactions using WATCH</a><br> <a href="#WATCH explained">WATCH explained</a><br> <a href="#WATCH used to implement ZPOP">WATCH used to implement ZPOP</a><br> <a href="#Return value">Return value</a>
|
20
|
+
</div>
|
21
|
+
|
22
|
+
<h1 class="wikiname">MultiExecCommand</h1>
|
23
|
+
|
24
|
+
<div class="summary">
|
25
|
+
|
26
|
+
</div>
|
27
|
+
|
28
|
+
<div class="narrow">
|
29
|
+
#sidebar <a href="GenericCommandsSidebar.html">GenericCommandsSidebar</a><h1><a name="WATCH key1 key2 ... keyN (Redis >">WATCH key1 key2 ... keyN (Redis ></a></h1> 2.1.0)=
|
30
|
+
<h1><a name="UNWATCH">UNWATCH</a></h1>
|
31
|
+
<h1><a name="MULTI">MULTI</a></h1>
|
32
|
+
<h1><a name="COMMAND_1 ...">COMMAND_1 ...</a></h1>
|
33
|
+
<h1><a name="COMMAND_2 ...">COMMAND_2 ...</a></h1>
|
34
|
+
<h1><a name="COMMAND_N ...">COMMAND_N ...</a></h1>
|
35
|
+
<h1><a name="EXEC or DISCARD">EXEC or DISCARD</a></h1>MULTI, EXEC, DISCARD and WATCH commands are the foundation of Redis Transactions.
|
36
|
+
A Redis Transaction allows the execution of a group of Redis commands in a single
|
37
|
+
step, with two important guarantees:<br/><br/><ul><li> All the commands in a transaction are serialized and executed sequentially. It can never happen that a request issued by another client is served <b>in the middle</b> of the execution of a Redis transaction. This guarantees that the commands are executed as a single atomic operation.</li><li> Either all of the commands or none are processed. The EXEC command triggers the execution of all the commands in the transaction, so if a client loses the connection to the server in the context of a transaction before calling the MULTI command none of the operations are performed, instead if the EXEC command is called, all the operations are performed. An exception to this rule is when the Append Only File is enabled: every command that is part of a Redis transaction will log in the AOF as long as the operation is completed, so if the Redis server crashes or is killed by the system administrator in some hard way it is possible that only a partial number of operations are registered.</li></ul>
|
38
|
+
Since Redis 2.1.0, it's also possible to add a further guarantee to the above two, in the form of optimistic locking of a set of keys in a way very similar to a CAS (check and set) operation. This is documented later in this manual page.<h2><a name="Usage">Usage</a></h2>A Redis transaction is entered using the MULTI command. The command always
|
39
|
+
replies with OK. At this point the user can issue multiple commands. Instead
|
40
|
+
of executing these commands, Redis will "queue" them. All the commands are
|
41
|
+
executed once EXEC is called.<br/><br/>Calling DISCARD instead will flush the transaction queue and will exit
|
42
|
+
the transaction.<br/><br/>The following is an example using the Ruby client:
|
43
|
+
<pre class="codeblock python" name="code">
|
44
|
+
?> r.multi
|
45
|
+
=> "OK"
|
46
|
+
>> r.incr "foo"
|
47
|
+
=> "QUEUED"
|
48
|
+
>> r.incr "bar"
|
49
|
+
=> "QUEUED"
|
50
|
+
>> r.incr "bar"
|
51
|
+
=> "QUEUED"
|
52
|
+
>> r.exec
|
53
|
+
=> [1, 1, 2]
|
54
|
+
</pre>
|
55
|
+
As it is possible to see from the session above, MULTI returns an "array" of
|
56
|
+
replies, where every element is the reply of a single command in the
|
57
|
+
transaction, in the same order the commands were queued.<br/><br/>When a Redis connection is in the context of a MULTI request, all the commands
|
58
|
+
will reply with a simple string "QUEUED" if they are correct from the
|
59
|
+
point of view of the syntax and arity (number of arguments) of the commaand.
|
60
|
+
Some commands are still allowed to fail during execution time.<br/><br/>This is more clear on the protocol level; In the following example one command
|
61
|
+
will fail when executed even if the syntax is right:
|
62
|
+
<pre class="codeblock python python" name="code">
|
63
|
+
Trying 127.0.0.1...
|
64
|
+
Connected to localhost.
|
65
|
+
Escape character is '^]'.
|
66
|
+
MULTI
|
67
|
+
+OK
|
68
|
+
SET a 3
|
69
|
+
abc
|
70
|
+
+QUEUED
|
71
|
+
LPOP a
|
72
|
+
+QUEUED
|
73
|
+
EXEC
|
74
|
+
*2
|
75
|
+
+OK
|
76
|
+
-ERR Operation against a key holding the wrong kind of value
|
77
|
+
</pre>
|
78
|
+
MULTI returned a two elements bulk reply where one is an +OK
|
79
|
+
code and one is a -ERR reply. It's up to the client lib to find a sensible
|
80
|
+
way to provide the error to the user.<br/><br/><blockquote>IMPORTANT: even when a command will raise an error, all the other commandsin the queue will be processed. Redis will NOT stop the processing ofcommands once an error is found.</blockquote>
|
81
|
+
Another example, again using the write protocol with telnet, shows how
|
82
|
+
syntax errors are reported ASAP instead:
|
83
|
+
<pre class="codeblock python python python" name="code">
|
84
|
+
MULTI
|
85
|
+
+OK
|
86
|
+
INCR a b c
|
87
|
+
-ERR wrong number of arguments for 'incr' command
|
88
|
+
</pre>
|
89
|
+
This time due to the syntax error the "bad" INCR command is not queued
|
90
|
+
at all.<h2><a name="The DISCARD command">The DISCARD command</a></h2>DISCARD can be used in order to abort a transaction. No command will be executed, and the state of the client is again the normal one, outside of a transaction. Example using the Ruby client:
|
91
|
+
<pre class="codeblock python python python python" name="code">
|
92
|
+
?> r.set("foo",1)
|
93
|
+
=> true
|
94
|
+
>> r.multi
|
95
|
+
=> "OK"
|
96
|
+
>> r.incr("foo")
|
97
|
+
=> "QUEUED"
|
98
|
+
>> r.discard
|
99
|
+
=> "OK"
|
100
|
+
>> r.get("foo")
|
101
|
+
=> "1"
|
102
|
+
</pre><h2><a name="Check and Set (CAS) transactions using WATCH">Check and Set (CAS) transactions using WATCH</a></h2>WATCH is used in order to provide a CAS (Check and Set) behavior to
|
103
|
+
Redis Transactions.<br/><br/>WATCHed keys are monitored in order to detect changes against this keys.
|
104
|
+
If at least a watched key will be modified before the EXEC call, the
|
105
|
+
whole transaction will abort, and EXEC will return a nil object
|
106
|
+
(A Null Multi Bulk reply) to notify that the transaction failed.<br/><br/>For example imagine we have the need to atomically increment the value
|
107
|
+
of a key by 1 (I know we have INCR, let's suppose we don't have it).<br/><br/>The first try may be the following:
|
108
|
+
<pre class="codeblock python python python python python" name="code">
|
109
|
+
val = GET mykey
|
110
|
+
val = val + 1
|
111
|
+
SET mykey $val
|
112
|
+
</pre>
|
113
|
+
This will work reliably only if we have a single client performing the operation in a given time.
|
114
|
+
If multiple clients will try to increment the key about at the same time
|
115
|
+
there will be a race condition. For instance client A and B will read the
|
116
|
+
old value, for instance, 10. The value will be incremented to 11 by both
|
117
|
+
the clients, and finally SET as the value of the key. So the final value
|
118
|
+
will be "11" instead of "12".<br/><br/>Thanks to WATCH we are able to model the problem very well:
|
119
|
+
<pre class="codeblock python python python python python python" name="code">
|
120
|
+
WATCH mykey
|
121
|
+
val = GET mykey
|
122
|
+
val = val + 1
|
123
|
+
MULTI
|
124
|
+
SET mykey $val
|
125
|
+
EXEC
|
126
|
+
</pre>
|
127
|
+
Using the above code, if there are race conditions and another client
|
128
|
+
modified the result of <i>val</i> in the time between our call to WATCH and
|
129
|
+
our call to EXEC, the transaction will fail.<br/><br/>We'll have just to re-iterate the operation hoping this time we'll not get
|
130
|
+
a new race. This form of locking is called <b>optimistic locking</b> and is
|
131
|
+
a very powerful form of locking as in many problems there are multiple
|
132
|
+
clients accessing a much bigger number of keys, so it's very unlikely that
|
133
|
+
there are collisions: usually operations don't need to be performed
|
134
|
+
multiple times.<h2><a name="WATCH explained">WATCH explained</a></h2>So what is WATCH really about? It is a command that will make the EXEC
|
135
|
+
conditional: we are asking Redis to perform the transaction only if no
|
136
|
+
other client modified any of the WATCHed keys. Otherwise the transaction is not
|
137
|
+
entered at all. (Note that if you WATCH a volatile key and Redis expires the key after you WATCHed it, EXEC will still work. <a href="http://code.google.com/p/redis/issues/detail?id=270" target="_blank">More</a>.)<br/><br/>WATCH can be called multiple times. Simply all the WATCH calls will
|
138
|
+
have the effects to watch for changes starting from the call, up to the
|
139
|
+
moment EXEC is called.<br/><br/>When EXEC is called, either if it will fail or succeed, all keys are
|
140
|
+
UNWATCHed. Also when a client connection is closed, everything gets
|
141
|
+
UNWATCHed.<br/><br/>It is also possible to use the UNWATCH command (without arguments) in order
|
142
|
+
to flush all the watched keys. Sometimes this is useful as we
|
143
|
+
optimistically lock a few keys, since possibly we need to perform a transaction
|
144
|
+
to alter those keys, but after reading the current content of the keys
|
145
|
+
we don't want to proceed. When this happens we just call UNWATCH so that
|
146
|
+
the connection can already be used freely for new transactions.<h2><a name="WATCH used to implement ZPOP">WATCH used to implement ZPOP</a></h2>A good example to illustrate how WATCH can be used to create new atomic
|
147
|
+
operations otherwise not supported by Redis is to implement ZPOP, that is
|
148
|
+
a command that pops the element with the lower score from a sorted set
|
149
|
+
in an atomic way. This is the simplest implementation:
|
150
|
+
<pre class="codeblock python python python python python python python" name="code">
|
151
|
+
WATCH zset
|
152
|
+
ele = ZRANGE zset 0 0
|
153
|
+
MULTI
|
154
|
+
ZREM zset ele
|
155
|
+
EXEC
|
156
|
+
</pre>
|
157
|
+
If EXEC fails (returns a nil value) we just re-iterate the operation.<h2><a name="Return value">Return value</a></h2><a href="ReplyTypes.html">Multi bulk reply</a>, specifically:<br/><br/><pre class="codeblock python python python python python python python python" name="code">
|
158
|
+
The result of a MULTI/EXEC command is a multi bulk reply where every element is the return value of every command in the atomic transaction.
|
159
|
+
</pre>If a MULTI/EXEC transaction is aborted because of WATCH detected modified keys, a <a href="ReplyTypes.html">Null Multi Bulk reply</a> is returned.
|
160
|
+
</div>
|
161
|
+
|
162
|
+
</div>
|
163
|
+
</div>
|
164
|
+
</body>
|
165
|
+
</html>
|
166
|
+
|
@@ -0,0 +1,51 @@
|
|
1
|
+
|
2
|
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<link type="text/css" rel="stylesheet" href="style.css" />
|
6
|
+
</head>
|
7
|
+
<body>
|
8
|
+
<div id="page">
|
9
|
+
|
10
|
+
<div id='header'>
|
11
|
+
<a href="index.html">
|
12
|
+
<img style="border:none" alt="Redis Documentation" src="redis.png">
|
13
|
+
</a>
|
14
|
+
</div>
|
15
|
+
|
16
|
+
<div id="pagecontent">
|
17
|
+
<div class="index">
|
18
|
+
<!-- This is a (PRE) block. Make sure it's left aligned or your toc title will be off. -->
|
19
|
+
<b>NonexistentCommands: Contents</b><br> <a href="#HGETSET">HGETSET</a><br> <a href="#SET with expire">SET with expire</a><br> <a href="#ZADDNX">ZADDNX</a>
|
20
|
+
</div>
|
21
|
+
|
22
|
+
<h1 class="wikiname">NonexistentCommands</h1>
|
23
|
+
|
24
|
+
<div class="summary">
|
25
|
+
A list of commands that don't exist in Redis, but can be accomplished in a different way.
|
26
|
+
</div>
|
27
|
+
|
28
|
+
<div class="narrow">
|
29
|
+
|
30
|
+
This is a list of commands that don't exist in Redis, but can be accomplished in a different way, usually by means of <a href="MultiExecCommand.html">WATCH/MULTI/EXEC</a>.<br/><br/>For better performance, you can pipeline multiple commands.<h1><a name="HGETSET">HGETSET</a></h1><a href="GetsetCommand.html">GETSET</a> for Hashes.<br/><br/><pre class="codeblock python" name="code">
|
31
|
+
WATCH foo
|
32
|
+
old_value = HGET foo field
|
33
|
+
MULTI
|
34
|
+
HSET foo field new_value
|
35
|
+
EXEC
|
36
|
+
</pre><h1><a name="SET with expire">SET with expire</a></h1>See <a href="SetexCommand.html">SETEX</a>.<h1><a name="ZADDNX">ZADDNX</a></h1>Add an element to a sorted set, only if the element doesn't already exist (by default, <a href="ZaddCommand.html">ZADD</a> would update the element's score if it already exists). <a href="http://groups.google.com/group/redis-db/browse_thread/thread/fc4c79d72e5bd346/6cdc07ecc36b81e7" target="_blank">See thread</a>.<br/><br/><pre class="codeblock python python" name="code">
|
37
|
+
WATCH foo
|
38
|
+
score = ZSCORE foo bar
|
39
|
+
IF score != NIL
|
40
|
+
MULTI
|
41
|
+
ZADD foo 1 bar
|
42
|
+
EXEC
|
43
|
+
ENDIF
|
44
|
+
</pre>
|
45
|
+
</div>
|
46
|
+
|
47
|
+
</div>
|
48
|
+
</div>
|
49
|
+
</body>
|
50
|
+
</html>
|
51
|
+
|
@@ -0,0 +1,39 @@
|
|
1
|
+
|
2
|
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<link type="text/css" rel="stylesheet" href="style.css" />
|
6
|
+
</head>
|
7
|
+
<body>
|
8
|
+
<div id="page">
|
9
|
+
|
10
|
+
<div id='header'>
|
11
|
+
<a href="index.html">
|
12
|
+
<img style="border:none" alt="Redis Documentation" src="redis.png">
|
13
|
+
</a>
|
14
|
+
</div>
|
15
|
+
|
16
|
+
<div id="pagecontent">
|
17
|
+
<div class="index">
|
18
|
+
<!-- This is a (PRE) block. Make sure it's left aligned or your toc title will be off. -->
|
19
|
+
<b>ObjectHashMappers: Contents</b><br> <a href="#Object Hash Mappers">Object Hash Mappers</a><br> <a href="#Ruby">Ruby</a><br> <a href="#Ohm">Ohm</a><br> <a href="#dm-redis-adapter">dm-redis-adapter</a><br> <a href="#redis-models">redis-models</a>
|
20
|
+
</div>
|
21
|
+
|
22
|
+
<h1 class="wikiname">ObjectHashMappers</h1>
|
23
|
+
|
24
|
+
<div class="summary">
|
25
|
+
|
26
|
+
</div>
|
27
|
+
|
28
|
+
<div class="narrow">
|
29
|
+
|
30
|
+
<h1><a name="Object Hash Mappers">Object Hash Mappers</a></h1>Looking for a higher level if abstraction for your Objects, their Properties and Relationships?<br/><br/>There is not need to stick to the <a href="SupportedLanguages.html">client libraries</a> exposing the raw features of Redis, here you will find a list of <b>Object Hash Mappers</b>, working in the same fashion a ORM does.<h2><a name="Ruby">Ruby</a></h2><h3><a name="Ohm">Ohm</a></h3><ul><li> Object-hash mapping library for Redis. It includes an extensible list of validations and has very good performance.</li><li> Authors: <a href="http://soveran.com/" target="_blank">Michel Martens</a>, <a href="http://twitter.com/soveran" target="_blank">@soveran</a>; and Damian Janowski <a href="http://twitter.com/djanowski" target="_blank">@djanowski</a>.</li><li> Repository: <a href="http://github.com/soveran/ohm" target="_blank">http://github.com/soveran/ohm</a></li><li> Group: <a href="http://groups.google.com/group/ohm-ruby" target="_blank">http://groups.google.com/group/ohm-ruby</a></li></ul>
|
31
|
+
<h3><a name="dm-redis-adapter">dm-redis-adapter</a></h3><ul><li> This is a DataMapper (ORM that is based on the IdentityMap pattern) adapter for the Redis key-value database.</li><li> Author: <a href="http://whoahbot.com/" target="_blank">Whoahbot</a>, <a href="http://twitter.com/whoahbot" target="_blank">@whoahbot</a>.</li><li> Repository: <a href="http://github.com/whoahbot/dm-redis-adapter/" target="_blank">http://github.com/whoahbot/dm-redis-adapter/</a></li></ul>
|
32
|
+
<h3><a name="redis-models">redis-models</a></h3><ul><li> Minimal model support for Redis. Directly maps Ruby properties to model_name:id:field_name keys in redis. Scalar, List and Set properties are supported. Values can be marshaled to/from Integer, Float, DateTime, JSON. </li><li> Repository: <a href="http://github.com/voloko/redis-model" target="_blank">http://github.com/voloko/redis-model</a></li></ul>
|
33
|
+
</div>
|
34
|
+
|
35
|
+
</div>
|
36
|
+
</div>
|
37
|
+
</body>
|
38
|
+
</html>
|
39
|
+
|
@@ -0,0 +1,36 @@
|
|
1
|
+
|
2
|
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<link type="text/css" rel="stylesheet" href="style.css" />
|
6
|
+
</head>
|
7
|
+
<body>
|
8
|
+
<div id="page">
|
9
|
+
|
10
|
+
<div id='header'>
|
11
|
+
<a href="index.html">
|
12
|
+
<img style="border:none" alt="Redis Documentation" src="redis.png">
|
13
|
+
</a>
|
14
|
+
</div>
|
15
|
+
|
16
|
+
<div id="pagecontent">
|
17
|
+
<div class="index">
|
18
|
+
<!-- This is a (PRE) block. Make sure it's left aligned or your toc title will be off. -->
|
19
|
+
<b>Pipelining: Contents</b><br> <a href="#Pipelining (DRAFT)">Pipelining (DRAFT)</a>
|
20
|
+
</div>
|
21
|
+
|
22
|
+
<h1 class="wikiname">Pipelining</h1>
|
23
|
+
|
24
|
+
<div class="summary">
|
25
|
+
|
26
|
+
</div>
|
27
|
+
|
28
|
+
<div class="narrow">
|
29
|
+
<h1><a name="Pipelining (DRAFT)">Pipelining (DRAFT)</a></h1>A client library can use the same connection in order to issue multiple commands. But Redis supports <b>pipelining</b>, so multiple commands can be sent to the server with a single write operation by the client, without need to read the server reply in order to issue the next command. All the replies can be read at the end.<br/><br/>Usually Redis server and client will have a very fast link so this is not very important to support this feature in a client implementation, still if an application needs to issue a very large number of commands in s short time, using pipelining can be much faster.<br/><br/>Please read the <a href="ProtocolSpecification.html">ProtocolSpecification</a> if you want to learn more about the way Redis <a href="SupportedLanguages.html">clients</a> and the server communicate.<br/><br/>Pipelining is one of the <a href="Speed.html">Speed</a> <a href="Features.html">Features</a> of Redis, you can also check the support for <a href="MultiBulkCommands.html">send and receive multiple values in a single command</a>.
|
30
|
+
</div>
|
31
|
+
|
32
|
+
</div>
|
33
|
+
</div>
|
34
|
+
</body>
|
35
|
+
</html>
|
36
|
+
|
@@ -0,0 +1,38 @@
|
|
1
|
+
|
2
|
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<link type="text/css" rel="stylesheet" href="style.css" />
|
6
|
+
</head>
|
7
|
+
<body>
|
8
|
+
<div id="page">
|
9
|
+
|
10
|
+
<div id='header'>
|
11
|
+
<a href="index.html">
|
12
|
+
<img style="border:none" alt="Redis Documentation" src="redis.png">
|
13
|
+
</a>
|
14
|
+
</div>
|
15
|
+
|
16
|
+
<div id="pagecontent">
|
17
|
+
<div class="index">
|
18
|
+
<!-- This is a (PRE) block. Make sure it's left aligned or your toc title will be off. -->
|
19
|
+
<b>ProgrammingExamples: Contents</b><br> <a href="#Programming Examples (DRAFT)">Programming Examples (DRAFT)</a><br> <a href="#TODO">TODO</a><br> <a href="#Java">Java</a><br> <a href="#Twayis">Twayis</a><br> <a href="#PHP">PHP</a><br> <a href="#Retwis">Retwis</a><br> <a href="#Ruby">Ruby</a><br> <a href="#twatcher-lite">twatcher-lite</a><br> <a href="#Resque">Resque</a><br> <a href="#Retwis-rb">Retwis-rb</a><br> <a href="#scanty-redis">scanty-redis</a><br> <a href="#Note Taking">Note Taking</a>
|
20
|
+
</div>
|
21
|
+
|
22
|
+
<h1 class="wikiname">ProgrammingExamples</h1>
|
23
|
+
|
24
|
+
<div class="summary">
|
25
|
+
|
26
|
+
</div>
|
27
|
+
|
28
|
+
<div class="narrow">
|
29
|
+
|
30
|
+
<h1><a name="Programming Examples (DRAFT)">Programming Examples (DRAFT)</a></h1><h2><a name="TODO">TODO</a></h2><ul><li> Add <a href="http://github.com/jodosha/redis-store" target="_blank">http://github.com/jodosha/redis-store</a></li></ul>
|
31
|
+
Nothing speaks better than code examples, here you are:<h2><a name="Java">Java</a></h2><h3><a name="Twayis">Twayis</a></h3> <br/><br/>A Java clone of <b>Retwis</b> showcase integration between the <a href="http://www.playframework.org/" target="_blank">Play! framework</a> and Redis <a href="http://code.google.com/p/twayis/" target="_blank">Google Code Project Page</a><h2><a name="PHP">PHP</a></h2><h3><a name="Retwis">Retwis</a></h3>A PHP Twitter clone, the original example of Redis capabilities. With a <a href="http://retwis.antirez.com/" target="_blank">live demo</a>, and an <a href="http://code.google.com/p/redis/wiki/TwitterAlikeExample" target="_blank">article explaining it design</a>. You can find the code in the Downloads tab.<h2><a name="Ruby">Ruby</a></h2><h3><a name="twatcher-lite">twatcher-lite</a></h3>A simplied version of the application running <a href="http://twatcher.com/" target="_blank">http://twatcher.com/</a> from Mirko Froehlich (<a href="http://twitter.com/digitalhobbit" target="_blank">@digitalhobbit</a>) with a full blog post explaining its development at <a href="http://www.digitalhobbit.com/2009/11/08/building-a-twitter-filter-with-sinatra-redis-and-tweetstream/" target="_blank"> Building a Twitter Filter With Sinatra, Redis, and TweetStream</a><h3><a name="Resque">Resque</a></h3>The "simple" Redis-based queue behind Github background jobs, that replaced SQS, Starling, ActiveMessaging, BackgroundJob, DelayedJob, and Beanstalkd. Developed by Chris Wanstrath (<a href="http://twitter.com/defunkt" target="_blank">@defunkt</a>) the code is at <a href="http://github.com/defunkt/resque" target="_blank">http://github.com/defunkt/resque</a>, be sure to read <a href="http://github.com/blog/542-introducing-resque" target="_blank">the introduction</a><h3><a name="Retwis-rb">Retwis-rb</a></h3>A port of <b>Retwis</b> to Ruby and <a href="http://www.sinatrarb.com/" target="_blank">Sinatra</a> written by Daniel Lucraft (<a href="http://twitter.com/DanLucraft" target="_blank">@DanLucraft</a>) Full source code is available at <a href="http://github.com/danlucraft/retwis-rb" target="_blank">http://github.com/danlucraft/retwis-rb</a><h3><a name="scanty-redis">scanty-redis</a></h3>Scanty is <i>minimal</i> blogging software developed by Adam Wiggins (<a href="http://twitter.com/hirodusk" target="_blank">@hirodusk</a>) It is not a blogging engine, but it�s small and easy to modify, so it could be the starting point for your blog. <a href="http://github.com/adamwiggins/scanty-redis" target="_blank">This fork</a> is modified to use Redis, a full featured key-value database, instead of SQL. <h3><a name="Note Taking">Note Taking</a></h3>A <i>very simple</i> note taking example of Ruby and Redis application using <a href="http://www.sinatrarb.com/" target="_blank">Sinatra</a>. Developed by Pieter Noordhuis <a href="http://twitter.com/pnoordhuis" target="_blank">@pnoordhuis</a>, you can check the code at <a href="http://gist.github.com/86714" target="_blank">http://gist.github.com/86714</a>
|
32
|
+
</div>
|
33
|
+
|
34
|
+
</div>
|
35
|
+
</div>
|
36
|
+
</body>
|
37
|
+
</html>
|
38
|
+
|
@@ -0,0 +1,137 @@
|
|
1
|
+
|
2
|
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<link type="text/css" rel="stylesheet" href="style.css" />
|
6
|
+
</head>
|
7
|
+
<body>
|
8
|
+
<div id="page">
|
9
|
+
|
10
|
+
<div id='header'>
|
11
|
+
<a href="index.html">
|
12
|
+
<img style="border:none" alt="Redis Documentation" src="redis.png">
|
13
|
+
</a>
|
14
|
+
</div>
|
15
|
+
|
16
|
+
<div id="pagecontent">
|
17
|
+
<div class="index">
|
18
|
+
<!-- This is a (PRE) block. Make sure it's left aligned or your toc title will be off. -->
|
19
|
+
<b>ProtocolSpecification: Contents</b><br> <a href="#Networking layer">Networking layer</a><br> <a href="#Requests">Requests</a><br> <a href="#The new unified request protocol">The new unified request protocol</a><br> <a href="#Replies">Replies</a><br> <a href="#Single line reply">Single line reply</a><br> <a href="#Error reply">Error reply</a><br> <a href="#Integer reply">Integer reply</a><br> <a href="#Bulk replies">Bulk replies</a><br> <a href="#Multi-Bulk replies">Multi-Bulk replies</a><br> <a href="#Nil elements in Multi-Bulk replies">Nil elements in Multi-Bulk replies</a><br> <a href="#Multiple commands and pipelining">Multiple commands and pipelining</a><br> <a href="#The old protocol for sending commands">The old protocol for sending commands</a><br> <a href="#Inline Commands">Inline Commands</a><br> <a href="#Bulk commands">Bulk commands</a>
|
20
|
+
</div>
|
21
|
+
|
22
|
+
<h1 class="wikiname">ProtocolSpecification</h1>
|
23
|
+
|
24
|
+
<div class="summary">
|
25
|
+
|
26
|
+
</div>
|
27
|
+
|
28
|
+
<div class="narrow">
|
29
|
+
= Protocol Specification =<br/><br/>The Redis protocol is a compromise between the following things:<br/><br/><ul><li> Simple to implement.</li><li> Fast to parse by a computer.</li><li> Easy enough to parse by a human.</li></ul>
|
30
|
+
<h2><a name="Networking layer">Networking layer</a></h2>A client connects to a Redis server creating a TCP connection to the port 6379.
|
31
|
+
Every Redis command or data transmitted by the client and the server is
|
32
|
+
terminated by "\r\n" (CRLF).<h1><a name="Requests">Requests</a></h1>Redis accepts commands composed of different arguments.
|
33
|
+
Once a command is received, it is processed and a reply is sent back to the client.<h2><a name="The new unified request protocol">The new unified request protocol</a></h2>The new unified protocol was introduced in Redis 1.2, but it became the standard way for talking with the Redis server in Redis 2.0.<br/><br/>In the unified protocol all the arguments sent to the Redis server are binary safe. This is the general form:<br/><br/><pre class="codeblock python" name="code">
|
34
|
+
*<number of arguments> CR LF
|
35
|
+
$<number of bytes of argument 1> CR LF
|
36
|
+
<argument data> CR LF
|
37
|
+
...
|
38
|
+
$<number of bytes of argument N> CR LF
|
39
|
+
<argument data> CR LF
|
40
|
+
</pre>See the following example:<br/><br/><pre class="codeblock python python" name="code">
|
41
|
+
*3
|
42
|
+
$3
|
43
|
+
SET
|
44
|
+
$5
|
45
|
+
mykey
|
46
|
+
$7
|
47
|
+
myvalue
|
48
|
+
</pre>This is how the above command looks as a quoted string, so that it is possible to see the exact value of every byte in the query:<br/><br/><pre class="codeblock python python python" name="code">
|
49
|
+
"*3\r\n$3\r\nSET\r\n$5\r\nmykey\r\n$8\r\nmyvalue\r\n"
|
50
|
+
</pre>As you will see in a moment this format is also used in Redis replies.
|
51
|
+
The format used for every argument "$6\r\nmydata\r\n" is called a Bulk Reply.
|
52
|
+
While the actual unified request protocol is what Redis uses to return list of items, and is called a Multi Bulk Reply. It is just the sum of N different
|
53
|
+
Bulk Replies prefixed by a <code name="code" class="python">*<argc>\r\n</code> string where <code name="code" class="python"><argc></code> is the number of arguments (Bulk Replies) that will follow.<h1><a name="Replies">Replies</a></h1>Redis will reply to commands with different kinds of replies. It is possible to check the kind of reply from the first byte sent by the server:<br/><br/><ul><li> With a single line reply the first byte of the reply will be "+"</li><li> With an error message the first byte of the reply will be "-"</li><li> With an integer number the first byte of the reply will be ":"</li><li> With bulk reply the first byte of the reply will be "$"</li><li> With multi-bulk reply the first byte of the reply will be "<code name="code" class="python">*</code>"</li></ul>
|
54
|
+
<h2><a name="Single line reply">Single line reply</a></h2>A single line reply is in the form of a single line string
|
55
|
+
starting with "+" terminated by "\r\n". For example:<br/><br/><pre class="codeblock python python python python" name="code">
|
56
|
+
+OK
|
57
|
+
</pre>The client library should return everything after the "+", that is, the string "OK" in the example.<br/><br/>The following commands reply with a single line reply:
|
58
|
+
PING, SET, SELECT, SAVE, BGSAVE, SHUTDOWN, RENAME, LPUSH, RPUSH, LSET, LTRIM<h2><a name="Error reply">Error reply</a></h2>Errors are sent exactly like Single Line Replies. The only difference is that the first byte is "-" instead of "+".<br/><br/>Error replies are only sent when something strange happened, for instance if you try to perform an operation against the wrong data type, or if the command does not exist and so forth. So an exception should be raised by the library client when an Error Reply is received.<h2><a name="Integer reply">Integer reply</a></h2>This type of reply is just a CRLF terminated string representing an integer, prefixed by a ":" byte. For example ":0\r\n", or ":1000\r\n" are integer replies.<br/><br/>With commands like INCR or LASTSAVE using the integer reply to actually return a value there is no special meaning for the returned integer. It is just an incremental number for INCR, a UNIX time for LASTSAVE and so on.<br/><br/>Some commands like EXISTS will return 1 for true and 0 for false.<br/><br/>Other commands like SADD, SREM and SETNX will return 1 if the operation was actually done, 0 otherwise.<br/><br/>The following commands will reply with an integer reply: SETNX, DEL, EXISTS, INCR, INCRBY, DECR, DECRBY, DBSIZE, LASTSAVE, RENAMENX, MOVE, LLEN, SADD, SREM, SISMEMBER, SCARD<h2><a name="Bulk replies">Bulk replies</a></h2>Bulk replies are used by the server in order to return a single binary safe string.<br/><br/><pre class="codeblock python python python python python" name="code">
|
59
|
+
C: GET mykey
|
60
|
+
S: $6
|
61
|
+
S: foobar
|
62
|
+
</pre>The server sends as the first line a "$" byte followed by the number of bytes
|
63
|
+
of the actual reply, followed by CRLF, then the actual data bytes are sent,
|
64
|
+
followed by additional two bytes for the final CRLF.
|
65
|
+
The exact sequence sent by the server is:<br/><br/><pre class="codeblock python python python python python python" name="code">
|
66
|
+
"$6\r\nfoobar\r\n"
|
67
|
+
</pre>If the requested value does not exist the bulk reply will use the special
|
68
|
+
value -1 as data length, example:<br/><br/><pre class="codeblock python python python python python python python" name="code">
|
69
|
+
C: GET nonexistingkey
|
70
|
+
S: $-1
|
71
|
+
</pre>The client library API should not return an empty string, but a nil object, when the requested object does not exist.
|
72
|
+
For example a Ruby library should return 'nil' while a C library should return
|
73
|
+
NULL (or set a special flag in the reply object), and so forth.<h2><a name="Multi-Bulk replies">Multi-Bulk replies</a></h2>Commands like LRANGE need to return multiple values (every element
|
74
|
+
of the list is a value, and LRANGE needs to return more than a single element). This is accomplished using multiple bulk writes,
|
75
|
+
prefixed by an initial line indicating how many bulk writes will follow.
|
76
|
+
The first byte of a multi bulk reply is always <code name="code" class="python">*</code>. Example:<br/><br/><pre class="codeblock python python python python python python python python" name="code">
|
77
|
+
C: LRANGE mylist 0 3
|
78
|
+
S: *4
|
79
|
+
S: $3
|
80
|
+
S: foo
|
81
|
+
S: $3
|
82
|
+
S: bar
|
83
|
+
S: $5
|
84
|
+
S: Hello
|
85
|
+
S: $5
|
86
|
+
S: World
|
87
|
+
</pre>As you can see the multi bulk reply is exactly the same format used in order
|
88
|
+
to send commands to the Redis server unsing the unified protocol.<br/><br/>The first line the server sent is "<b>4\r\n" in order to specify that four bulk
|
89
|
+
replies will follow. Then every bulk write is transmitted.<br/><br/>If the specified key does not exist, instead of the number of elements in the
|
90
|
+
list the special value -1 is sent as count. Example:<br/><br/><pre class="codeblock python python python python python python python python python" name="code">
|
91
|
+
C: LRANGE nokey 0 1
|
92
|
+
S: *-1
|
93
|
+
</pre>A client library API SHOULD return a nil object and not an empty list when this
|
94
|
+
happens. This makes possible to distinguish between empty list and other error conditions (for instance a timeout condition in the BLPOP command).<h2><a name="Nil elements in Multi-Bulk replies">Nil elements in Multi-Bulk replies</a></h2>Single elements of a multi bulk reply may have -1 length, in order to signal that this elements are missing and not empty strings. This can happen with the SORT command when used with the GET <i>pattern</i> option when the specified key is missing. Example of a multi bulk reply containing an empty element:<br/><br/><pre class="codeblock python python python python python python python python python python" name="code">
|
95
|
+
S: *3
|
96
|
+
S: $3
|
97
|
+
S: foo
|
98
|
+
S: $-1
|
99
|
+
S: $3
|
100
|
+
S: bar
|
101
|
+
</pre>The second element is nul. The client library should return something like this:<br/><br/><pre class="codeblock python python python python python python python python python python python" name="code">
|
102
|
+
["foo",nil,"bar"]
|
103
|
+
</pre><h2><a name="Multiple commands and pipelining">Multiple commands and pipelining</a></h2>A client can use the same connection in order to issue multiple commands.
|
104
|
+
Pipelining is supported so multiple commands can be sent with a single
|
105
|
+
write operation by the client, it is not needed to read the server reply
|
106
|
+
in order to issue the next command. All the replies can be read at the end.<br/><br/>Usually Redis server and client will have a very fast link so this is not
|
107
|
+
very important to support this feature in a client implementation, still
|
108
|
+
if an application needs to issue a very large number of commands in short
|
109
|
+
time to use pipelining can be much faster.<h1><a name="The old protocol for sending commands">The old protocol for sending commands</a></h1>Before of the Unified Request Protocol Redis used a different protocol to send
|
110
|
+
commands, that is still supported since it is simpler to type by hand via telnet. In this protocol there are two kind of commands:<br/><br/><blockquote>* Inline commands: simple commands where argumnets are just space separated strings. No binary safeness is possible.* Bulk commands: bulk commands are exactly like inline commands, but the last argument is handled in a special way in order to allow for a binary-safe last argument.</blockquote>
|
111
|
+
<h2><a name="Inline Commands">Inline Commands</a></h2>The simplest way to send Redis a command is via </b>Inline Commands.
|
112
|
+
The following is an example of a server/client chat using an inline command (the server chat starts with S:, the client chat with C:)<br/><br/><pre class="codeblock python python python python python python python python python python python python" name="code">
|
113
|
+
C: PING
|
114
|
+
S: +PONG
|
115
|
+
</pre>The following is another example of an INLINE command returning an integer:<br/><br/><pre class="codeblock python python python python python python python python python python python python python" name="code">
|
116
|
+
C: EXISTS somekey
|
117
|
+
S: :0
|
118
|
+
</pre>Since 'somekey' does not exist the server returned ':0'.<br/><br/>Note that the EXISTS command takes one argument. Arguments are separated
|
119
|
+
by spaces.<h2><a name="Bulk commands">Bulk commands</a></h2>Some commands when sent as inline commands require a special form in order
|
120
|
+
to support a binary safe last argument. This commands will use the last argument
|
121
|
+
for a "byte count", then the bulk data is sent (that can be binary safe since
|
122
|
+
the server knows how many bytes to read).<br/><br/>See for instance the following example:<br/><br/><pre class="codeblock python python python python python python python python python python python python python python" name="code">
|
123
|
+
C: SET mykey 6
|
124
|
+
C: foobar
|
125
|
+
S: +OK
|
126
|
+
</pre>The last argument of the commnad is '6'. This specify the number of DATA
|
127
|
+
bytes that will follow, that is, the string "foobar". Note that even this bytes are terminated by two additional bytes of CRLF.<br/><br/>All the bulk commands are in this exact form: instead of the last argument
|
128
|
+
the number of bytes that will follow is specified, followed by the bytes
|
129
|
+
composing the argument itself, and CRLF. In order to be more clear for the programmer this is the string sent by the client in the above sample:<br/><br/><blockquote>"SET mykey 6\r\nfoobar\r\n"</blockquote>
|
130
|
+
Redis has an internal list of what command is inline and what command is bulk, so you have to send this commands accordingly. It is strongly suggested to use the new Unified Request Protocol instead.
|
131
|
+
</div>
|
132
|
+
|
133
|
+
</div>
|
134
|
+
</div>
|
135
|
+
</body>
|
136
|
+
</html>
|
137
|
+
|