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.
Files changed (290) hide show
  1. data/LICENSE +38 -0
  2. data/README.md +33 -0
  3. data/bin/redis +114 -0
  4. data/redis/Makefile +5 -0
  5. data/redis/extconf.rb +3 -0
  6. data/redis/redis-2.2.11/00-RELEASENOTES +199 -0
  7. data/redis/redis-2.2.11/BUGS +1 -0
  8. data/redis/redis-2.2.11/CONTRIBUTING +13 -0
  9. data/redis/redis-2.2.11/COPYING +10 -0
  10. data/redis/redis-2.2.11/Changelog +1032 -0
  11. data/redis/redis-2.2.11/INSTALL +30 -0
  12. data/redis/redis-2.2.11/Makefile +22 -0
  13. data/redis/redis-2.2.11/README +83 -0
  14. data/redis/redis-2.2.11/TODO +4 -0
  15. data/redis/redis-2.2.11/client-libraries/README +11 -0
  16. data/redis/redis-2.2.11/deps/hiredis/COPYING +10 -0
  17. data/redis/redis-2.2.11/deps/hiredis/Makefile +115 -0
  18. data/redis/redis-2.2.11/deps/hiredis/README.md +311 -0
  19. data/redis/redis-2.2.11/deps/hiredis/TODO +2 -0
  20. data/redis/redis-2.2.11/deps/hiredis/adapters/ae.h +95 -0
  21. data/redis/redis-2.2.11/deps/hiredis/adapters/libev.h +113 -0
  22. data/redis/redis-2.2.11/deps/hiredis/adapters/libevent.h +76 -0
  23. data/redis/redis-2.2.11/deps/hiredis/async.c +321 -0
  24. data/redis/redis-2.2.11/deps/hiredis/async.h +112 -0
  25. data/redis/redis-2.2.11/deps/hiredis/example-ae.c +53 -0
  26. data/redis/redis-2.2.11/deps/hiredis/example-libev.c +47 -0
  27. data/redis/redis-2.2.11/deps/hiredis/example-libevent.c +48 -0
  28. data/redis/redis-2.2.11/deps/hiredis/example.c +67 -0
  29. data/redis/redis-2.2.11/deps/hiredis/fmacros.h +15 -0
  30. data/redis/redis-2.2.11/deps/hiredis/hiredis.c +1058 -0
  31. data/redis/redis-2.2.11/deps/hiredis/hiredis.h +170 -0
  32. data/redis/redis-2.2.11/deps/hiredis/net.c +170 -0
  33. data/redis/redis-2.2.11/deps/hiredis/net.h +43 -0
  34. data/redis/redis-2.2.11/deps/hiredis/sds.c +479 -0
  35. data/redis/redis-2.2.11/deps/hiredis/sds.h +77 -0
  36. data/redis/redis-2.2.11/deps/hiredis/test.c +479 -0
  37. data/redis/redis-2.2.11/deps/hiredis/util.h +40 -0
  38. data/redis/redis-2.2.11/deps/linenoise/Makefile +10 -0
  39. data/redis/redis-2.2.11/deps/linenoise/README.markdown +45 -0
  40. data/redis/redis-2.2.11/deps/linenoise/example.c +27 -0
  41. data/redis/redis-2.2.11/deps/linenoise/linenoise.c +609 -0
  42. data/redis/redis-2.2.11/deps/linenoise/linenoise.h +55 -0
  43. data/redis/redis-2.2.11/design-documents/REDIS-CLUSTER +214 -0
  44. data/redis/redis-2.2.11/design-documents/REDIS-CLUSTER-2 +343 -0
  45. data/redis/redis-2.2.11/doc/AppendCommand.html +48 -0
  46. data/redis/redis-2.2.11/doc/AppendOnlyFileHowto.html +41 -0
  47. data/redis/redis-2.2.11/doc/AuthCommand.html +39 -0
  48. data/redis/redis-2.2.11/doc/Benchmarks.html +129 -0
  49. data/redis/redis-2.2.11/doc/BgrewriteaofCommand.html +41 -0
  50. data/redis/redis-2.2.11/doc/BgsaveCommand.html +39 -0
  51. data/redis/redis-2.2.11/doc/BlpopCommand.html +51 -0
  52. data/redis/redis-2.2.11/doc/BrpoplpushCommand.html +39 -0
  53. data/redis/redis-2.2.11/doc/CommandReference.html +47 -0
  54. data/redis/redis-2.2.11/doc/Comparisons.html +42 -0
  55. data/redis/redis-2.2.11/doc/ConfigCommand.html +76 -0
  56. data/redis/redis-2.2.11/doc/Configuration.html +38 -0
  57. data/redis/redis-2.2.11/doc/ConnectionHandlingSidebar.html +36 -0
  58. data/redis/redis-2.2.11/doc/ControlCommandsSidebar.html +36 -0
  59. data/redis/redis-2.2.11/doc/Credits.html +38 -0
  60. data/redis/redis-2.2.11/doc/DbsizeCommand.html +38 -0
  61. data/redis/redis-2.2.11/doc/DelCommand.html +41 -0
  62. data/redis/redis-2.2.11/doc/DesignPatterns.html +37 -0
  63. data/redis/redis-2.2.11/doc/EventLibray.html +44 -0
  64. data/redis/redis-2.2.11/doc/ExistsCommand.html +42 -0
  65. data/redis/redis-2.2.11/doc/ExpireCommand.html +96 -0
  66. data/redis/redis-2.2.11/doc/FAQ.html +70 -0
  67. data/redis/redis-2.2.11/doc/Features.html +38 -0
  68. data/redis/redis-2.2.11/doc/FlushallCommand.html +39 -0
  69. data/redis/redis-2.2.11/doc/FlushdbCommand.html +39 -0
  70. data/redis/redis-2.2.11/doc/FromSqlToDataStructures.html +37 -0
  71. data/redis/redis-2.2.11/doc/GenericCommandsSidebar.html +36 -0
  72. data/redis/redis-2.2.11/doc/GetCommand.html +39 -0
  73. data/redis/redis-2.2.11/doc/GetbitCommand.html +39 -0
  74. data/redis/redis-2.2.11/doc/GetsetCommand.html +38 -0
  75. data/redis/redis-2.2.11/doc/HackingStrings.html +83 -0
  76. data/redis/redis-2.2.11/doc/HashCommandsSidebar.html +36 -0
  77. data/redis/redis-2.2.11/doc/Hashes.html +37 -0
  78. data/redis/redis-2.2.11/doc/HdelCommand.html +39 -0
  79. data/redis/redis-2.2.11/doc/HexistsCommand.html +39 -0
  80. data/redis/redis-2.2.11/doc/HgetCommand.html +39 -0
  81. data/redis/redis-2.2.11/doc/HgetallCommand.html +40 -0
  82. data/redis/redis-2.2.11/doc/HincrbyCommand.html +45 -0
  83. data/redis/redis-2.2.11/doc/HlenCommand.html +38 -0
  84. data/redis/redis-2.2.11/doc/HmgetCommand.html +40 -0
  85. data/redis/redis-2.2.11/doc/HmsetCommand.html +40 -0
  86. data/redis/redis-2.2.11/doc/HsetCommand.html +40 -0
  87. data/redis/redis-2.2.11/doc/HsetnxCommand.html +41 -0
  88. data/redis/redis-2.2.11/doc/IncrCommand.html +43 -0
  89. data/redis/redis-2.2.11/doc/InfoCommand.html +48 -0
  90. data/redis/redis-2.2.11/doc/IntroductionToRedisDataTypes.html +152 -0
  91. data/redis/redis-2.2.11/doc/KeysCommand.html +43 -0
  92. data/redis/redis-2.2.11/doc/LastsaveCommand.html +39 -0
  93. data/redis/redis-2.2.11/doc/LindexCommand.html +40 -0
  94. data/redis/redis-2.2.11/doc/ListCommandsSidebar.html +36 -0
  95. data/redis/redis-2.2.11/doc/Lists.html +42 -0
  96. data/redis/redis-2.2.11/doc/LlenCommand.html +41 -0
  97. data/redis/redis-2.2.11/doc/LpopCommand.html +41 -0
  98. data/redis/redis-2.2.11/doc/LrangeCommand.html +47 -0
  99. data/redis/redis-2.2.11/doc/LremCommand.html +41 -0
  100. data/redis/redis-2.2.11/doc/LsetCommand.html +38 -0
  101. data/redis/redis-2.2.11/doc/LtrimCommand.html +47 -0
  102. data/redis/redis-2.2.11/doc/MgetCommand.html +52 -0
  103. data/redis/redis-2.2.11/doc/MonitorCommand.html +63 -0
  104. data/redis/redis-2.2.11/doc/MoveCommand.html +42 -0
  105. data/redis/redis-2.2.11/doc/MsetCommand.html +44 -0
  106. data/redis/redis-2.2.11/doc/MultiExecCommand.html +166 -0
  107. data/redis/redis-2.2.11/doc/NonexistentCommands.html +51 -0
  108. data/redis/redis-2.2.11/doc/ObjectHashMappers.html +39 -0
  109. data/redis/redis-2.2.11/doc/Pipelining.html +36 -0
  110. data/redis/redis-2.2.11/doc/ProgrammingExamples.html +38 -0
  111. data/redis/redis-2.2.11/doc/ProtocolSpecification.html +137 -0
  112. data/redis/redis-2.2.11/doc/PublishSubscribe.html +115 -0
  113. data/redis/redis-2.2.11/doc/QuickStart.html +68 -0
  114. data/redis/redis-2.2.11/doc/QuitCommand.html +38 -0
  115. data/redis/redis-2.2.11/doc/README.html +119 -0
  116. data/redis/redis-2.2.11/doc/RandomkeyCommand.html +39 -0
  117. data/redis/redis-2.2.11/doc/Redis0100ChangeLog.html +67 -0
  118. data/redis/redis-2.2.11/doc/Redis0900ChangeLog.html +56 -0
  119. data/redis/redis-2.2.11/doc/RedisBigData.html +61 -0
  120. data/redis/redis-2.2.11/doc/RedisCLI.html +37 -0
  121. data/redis/redis-2.2.11/doc/RedisEventLibrary.html +70 -0
  122. data/redis/redis-2.2.11/doc/RedisGuides.html +37 -0
  123. data/redis/redis-2.2.11/doc/RedisInternals.html +38 -0
  124. data/redis/redis-2.2.11/doc/RedisPipelining.html +93 -0
  125. data/redis/redis-2.2.11/doc/RedisStatus.html +56 -0
  126. data/redis/redis-2.2.11/doc/Redis_1_2_0_Changelog.html +40 -0
  127. data/redis/redis-2.2.11/doc/Redis_2_0_0_Changelog.html +62 -0
  128. data/redis/redis-2.2.11/doc/Redis_2_0_Whats_new.html +59 -0
  129. data/redis/redis-2.2.11/doc/RenameCommand.html +39 -0
  130. data/redis/redis-2.2.11/doc/RenamenxCommand.html +42 -0
  131. data/redis/redis-2.2.11/doc/ReplicationHowto.html +43 -0
  132. data/redis/redis-2.2.11/doc/ReplyTypes.html +42 -0
  133. data/redis/redis-2.2.11/doc/RoadMap.html +38 -0
  134. data/redis/redis-2.2.11/doc/RpoplpushCommand.html +44 -0
  135. data/redis/redis-2.2.11/doc/RpushCommand.html +40 -0
  136. data/redis/redis-2.2.11/doc/SaddCommand.html +41 -0
  137. data/redis/redis-2.2.11/doc/SaveCommand.html +39 -0
  138. data/redis/redis-2.2.11/doc/ScardCommand.html +41 -0
  139. data/redis/redis-2.2.11/doc/SdiffCommand.html +45 -0
  140. data/redis/redis-2.2.11/doc/SdiffstoreCommand.html +38 -0
  141. data/redis/redis-2.2.11/doc/SelectCommand.html +39 -0
  142. data/redis/redis-2.2.11/doc/SetCommand.html +39 -0
  143. data/redis/redis-2.2.11/doc/SetCommandsSidebar.html +36 -0
  144. data/redis/redis-2.2.11/doc/SetbitCommand.html +45 -0
  145. data/redis/redis-2.2.11/doc/SetexCommand.html +42 -0
  146. data/redis/redis-2.2.11/doc/SetnxCommand.html +51 -0
  147. data/redis/redis-2.2.11/doc/SetrangeCommand.html +58 -0
  148. data/redis/redis-2.2.11/doc/Sets.html +36 -0
  149. data/redis/redis-2.2.11/doc/ShutdownCommand.html +39 -0
  150. data/redis/redis-2.2.11/doc/SideBar.html +36 -0
  151. data/redis/redis-2.2.11/doc/SinterCommand.html +40 -0
  152. data/redis/redis-2.2.11/doc/SinterstoreCommand.html +39 -0
  153. data/redis/redis-2.2.11/doc/SismemberCommand.html +42 -0
  154. data/redis/redis-2.2.11/doc/SlaveofCommand.html +41 -0
  155. data/redis/redis-2.2.11/doc/SmembersCommand.html +38 -0
  156. data/redis/redis-2.2.11/doc/SmoveCommand.html +44 -0
  157. data/redis/redis-2.2.11/doc/SortCommand.html +75 -0
  158. data/redis/redis-2.2.11/doc/SortedSetCommandsSidebar.html +36 -0
  159. data/redis/redis-2.2.11/doc/SortedSets.html +36 -0
  160. data/redis/redis-2.2.11/doc/Speed.html +38 -0
  161. data/redis/redis-2.2.11/doc/SponsorshipHistory.html +38 -0
  162. data/redis/redis-2.2.11/doc/SpopCommand.html +40 -0
  163. data/redis/redis-2.2.11/doc/SrandmemberCommand.html +40 -0
  164. data/redis/redis-2.2.11/doc/SremCommand.html +42 -0
  165. data/redis/redis-2.2.11/doc/StringCommandsSidebar.html +36 -0
  166. data/redis/redis-2.2.11/doc/Strings.html +37 -0
  167. data/redis/redis-2.2.11/doc/StrlenCommand.html +39 -0
  168. data/redis/redis-2.2.11/doc/SubstrCommand.html +52 -0
  169. data/redis/redis-2.2.11/doc/SunionCommand.html +40 -0
  170. data/redis/redis-2.2.11/doc/SunionstoreCommand.html +38 -0
  171. data/redis/redis-2.2.11/doc/SupportedLanguages.html +60 -0
  172. data/redis/redis-2.2.11/doc/SupportedPlatforms.html +37 -0
  173. data/redis/redis-2.2.11/doc/TemplateCommand.html +38 -0
  174. data/redis/redis-2.2.11/doc/TtlCommand.html +38 -0
  175. data/redis/redis-2.2.11/doc/TwitterAlikeExample.html +250 -0
  176. data/redis/redis-2.2.11/doc/TypeCommand.html +46 -0
  177. data/redis/redis-2.2.11/doc/UnstableSource.html +39 -0
  178. data/redis/redis-2.2.11/doc/VirtualMemorySpecification.html +156 -0
  179. data/redis/redis-2.2.11/doc/VirtualMemoryUserGuide.html +66 -0
  180. data/redis/redis-2.2.11/doc/ZaddCommand.html +43 -0
  181. data/redis/redis-2.2.11/doc/ZcardCommand.html +41 -0
  182. data/redis/redis-2.2.11/doc/ZincrbyCommand.html +42 -0
  183. data/redis/redis-2.2.11/doc/ZrangeCommand.html +42 -0
  184. data/redis/redis-2.2.11/doc/ZrangebyscoreCommand.html +77 -0
  185. data/redis/redis-2.2.11/doc/ZrankCommand.html +43 -0
  186. data/redis/redis-2.2.11/doc/ZremCommand.html +42 -0
  187. data/redis/redis-2.2.11/doc/ZremrangebyrankCommand.html +39 -0
  188. data/redis/redis-2.2.11/doc/ZremrangebyscoreCommand.html +39 -0
  189. data/redis/redis-2.2.11/doc/ZscoreCommand.html +41 -0
  190. data/redis/redis-2.2.11/doc/ZunionCommand.html +42 -0
  191. data/redis/redis-2.2.11/doc/ZunionstoreCommand.html +43 -0
  192. data/redis/redis-2.2.11/doc/index.html +43 -0
  193. data/redis/redis-2.2.11/doc/redis.png +0 -0
  194. data/redis/redis-2.2.11/doc/style.css +25 -0
  195. data/redis/redis-2.2.11/redis.conf +417 -0
  196. data/redis/redis-2.2.11/src/Makefile +177 -0
  197. data/redis/redis-2.2.11/src/adlist.c +325 -0
  198. data/redis/redis-2.2.11/src/adlist.h +92 -0
  199. data/redis/redis-2.2.11/src/ae.c +390 -0
  200. data/redis/redis-2.2.11/src/ae.h +117 -0
  201. data/redis/redis-2.2.11/src/ae_epoll.c +91 -0
  202. data/redis/redis-2.2.11/src/ae_kqueue.c +93 -0
  203. data/redis/redis-2.2.11/src/ae_select.c +72 -0
  204. data/redis/redis-2.2.11/src/anet.c +347 -0
  205. data/redis/redis-2.2.11/src/anet.h +57 -0
  206. data/redis/redis-2.2.11/src/aof.c +675 -0
  207. data/redis/redis-2.2.11/src/config.c +627 -0
  208. data/redis/redis-2.2.11/src/config.h +64 -0
  209. data/redis/redis-2.2.11/src/db.c +543 -0
  210. data/redis/redis-2.2.11/src/debug.c +314 -0
  211. data/redis/redis-2.2.11/src/dict.c +721 -0
  212. data/redis/redis-2.2.11/src/dict.h +156 -0
  213. data/redis/redis-2.2.11/src/fmacros.h +15 -0
  214. data/redis/redis-2.2.11/src/help.h +638 -0
  215. data/redis/redis-2.2.11/src/intset.c +422 -0
  216. data/redis/redis-2.2.11/src/intset.h +19 -0
  217. data/redis/redis-2.2.11/src/lzf.h +100 -0
  218. data/redis/redis-2.2.11/src/lzfP.h +159 -0
  219. data/redis/redis-2.2.11/src/lzf_c.c +295 -0
  220. data/redis/redis-2.2.11/src/lzf_d.c +150 -0
  221. data/redis/redis-2.2.11/src/mkreleasehdr.sh +9 -0
  222. data/redis/redis-2.2.11/src/multi.c +268 -0
  223. data/redis/redis-2.2.11/src/networking.c +899 -0
  224. data/redis/redis-2.2.11/src/object.c +484 -0
  225. data/redis/redis-2.2.11/src/pqsort.c +197 -0
  226. data/redis/redis-2.2.11/src/pqsort.h +15 -0
  227. data/redis/redis-2.2.11/src/pubsub.c +267 -0
  228. data/redis/redis-2.2.11/src/rdb.c +1020 -0
  229. data/redis/redis-2.2.11/src/redis-benchmark.c +530 -0
  230. data/redis/redis-2.2.11/src/redis-check-aof.c +185 -0
  231. data/redis/redis-2.2.11/src/redis-check-dump.c +681 -0
  232. data/redis/redis-2.2.11/src/redis-cli.c +773 -0
  233. data/redis/redis-2.2.11/src/redis.c +1677 -0
  234. data/redis/redis-2.2.11/src/redis.h +1022 -0
  235. data/redis/redis-2.2.11/src/release.c +13 -0
  236. data/redis/redis-2.2.11/src/replication.c +557 -0
  237. data/redis/redis-2.2.11/src/sds.c +639 -0
  238. data/redis/redis-2.2.11/src/sds.h +78 -0
  239. data/redis/redis-2.2.11/src/sha1.c +276 -0
  240. data/redis/redis-2.2.11/src/sha1.h +17 -0
  241. data/redis/redis-2.2.11/src/solarisfixes.h +22 -0
  242. data/redis/redis-2.2.11/src/sort.c +389 -0
  243. data/redis/redis-2.2.11/src/syncio.c +154 -0
  244. data/redis/redis-2.2.11/src/t_hash.c +476 -0
  245. data/redis/redis-2.2.11/src/t_list.c +986 -0
  246. data/redis/redis-2.2.11/src/t_set.c +610 -0
  247. data/redis/redis-2.2.11/src/t_string.c +438 -0
  248. data/redis/redis-2.2.11/src/t_zset.c +1084 -0
  249. data/redis/redis-2.2.11/src/testhelp.h +54 -0
  250. data/redis/redis-2.2.11/src/util.c +243 -0
  251. data/redis/redis-2.2.11/src/valgrind.sup +5 -0
  252. data/redis/redis-2.2.11/src/version.h +1 -0
  253. data/redis/redis-2.2.11/src/vm.c +1149 -0
  254. data/redis/redis-2.2.11/src/ziplist.c +1323 -0
  255. data/redis/redis-2.2.11/src/ziplist.h +15 -0
  256. data/redis/redis-2.2.11/src/zipmap.c +455 -0
  257. data/redis/redis-2.2.11/src/zipmap.h +48 -0
  258. data/redis/redis-2.2.11/src/zmalloc.c +278 -0
  259. data/redis/redis-2.2.11/src/zmalloc.h +47 -0
  260. data/redis/redis-2.2.11/tests/assets/default.conf +308 -0
  261. data/redis/redis-2.2.11/tests/integration/aof.tcl +104 -0
  262. data/redis/redis-2.2.11/tests/integration/redis-cli.tcl +208 -0
  263. data/redis/redis-2.2.11/tests/integration/replication.tcl +98 -0
  264. data/redis/redis-2.2.11/tests/support/redis.tcl +241 -0
  265. data/redis/redis-2.2.11/tests/support/server.tcl +294 -0
  266. data/redis/redis-2.2.11/tests/support/test.tcl +190 -0
  267. data/redis/redis-2.2.11/tests/support/tmpfile.tcl +15 -0
  268. data/redis/redis-2.2.11/tests/support/util.tcl +296 -0
  269. data/redis/redis-2.2.11/tests/test_helper.tcl +221 -0
  270. data/redis/redis-2.2.11/tests/unit/auth.tcl +15 -0
  271. data/redis/redis-2.2.11/tests/unit/basic.tcl +616 -0
  272. data/redis/redis-2.2.11/tests/unit/cas.tcl +135 -0
  273. data/redis/redis-2.2.11/tests/unit/expire.tcl +74 -0
  274. data/redis/redis-2.2.11/tests/unit/other.tcl +240 -0
  275. data/redis/redis-2.2.11/tests/unit/printver.tcl +6 -0
  276. data/redis/redis-2.2.11/tests/unit/protocol.tcl +62 -0
  277. data/redis/redis-2.2.11/tests/unit/pubsub.tcl +195 -0
  278. data/redis/redis-2.2.11/tests/unit/quit.tcl +40 -0
  279. data/redis/redis-2.2.11/tests/unit/sort.tcl +189 -0
  280. data/redis/redis-2.2.11/tests/unit/type/hash.tcl +300 -0
  281. data/redis/redis-2.2.11/tests/unit/type/list.tcl +819 -0
  282. data/redis/redis-2.2.11/tests/unit/type/set.tcl +334 -0
  283. data/redis/redis-2.2.11/tests/unit/type/zset.tcl +587 -0
  284. data/redis/redis-2.2.11/utils/build-static-symbols.tcl +22 -0
  285. data/redis/redis-2.2.11/utils/generate-command-help.rb +112 -0
  286. data/redis/redis-2.2.11/utils/mktarball.sh +13 -0
  287. data/redis/redis-2.2.11/utils/redis-copy.rb +78 -0
  288. data/redis/redis-2.2.11/utils/redis-sha1.rb +52 -0
  289. data/redis/redis-2.2.11/utils/redis_init_script +42 -0
  290. metadata +362 -0
@@ -0,0 +1,15 @@
1
+ start_server {tags {"auth"} overrides {requirepass foobar}} {
2
+ test {AUTH fails when a wrong password is given} {
3
+ catch {r auth wrong!} err
4
+ format $err
5
+ } {ERR*invalid password}
6
+
7
+ test {Arbitrary command gives an error when AUTH is required} {
8
+ catch {r set foo bar} err
9
+ format $err
10
+ } {ERR*operation not permitted}
11
+
12
+ test {AUTH succeeds when the right password is given} {
13
+ r auth foobar
14
+ } {OK}
15
+ }
@@ -0,0 +1,616 @@
1
+ start_server {tags {"basic"}} {
2
+ test {DEL all keys to start with a clean DB} {
3
+ foreach key [r keys *] {r del $key}
4
+ r dbsize
5
+ } {0}
6
+
7
+ test {SET and GET an item} {
8
+ r set x foobar
9
+ r get x
10
+ } {foobar}
11
+
12
+ test {SET and GET an empty item} {
13
+ r set x {}
14
+ r get x
15
+ } {}
16
+
17
+ test {DEL against a single item} {
18
+ r del x
19
+ r get x
20
+ } {}
21
+
22
+ test {Vararg DEL} {
23
+ r set foo1 a
24
+ r set foo2 b
25
+ r set foo3 c
26
+ list [r del foo1 foo2 foo3 foo4] [r mget foo1 foo2 foo3]
27
+ } {3 {{} {} {}}}
28
+
29
+ test {KEYS with pattern} {
30
+ foreach key {key_x key_y key_z foo_a foo_b foo_c} {
31
+ r set $key hello
32
+ }
33
+ lsort [r keys foo*]
34
+ } {foo_a foo_b foo_c}
35
+
36
+ test {KEYS to get all keys} {
37
+ lsort [r keys *]
38
+ } {foo_a foo_b foo_c key_x key_y key_z}
39
+
40
+ test {DBSIZE} {
41
+ r dbsize
42
+ } {6}
43
+
44
+ test {DEL all keys} {
45
+ foreach key [r keys *] {r del $key}
46
+ r dbsize
47
+ } {0}
48
+
49
+ test {Very big payload in GET/SET} {
50
+ set buf [string repeat "abcd" 1000000]
51
+ r set foo $buf
52
+ r get foo
53
+ } [string repeat "abcd" 1000000]
54
+
55
+ tags {"slow"} {
56
+ test {Very big payload random access} {
57
+ set err {}
58
+ array set payload {}
59
+ for {set j 0} {$j < 100} {incr j} {
60
+ set size [expr 1+[randomInt 100000]]
61
+ set buf [string repeat "pl-$j" $size]
62
+ set payload($j) $buf
63
+ r set bigpayload_$j $buf
64
+ }
65
+ for {set j 0} {$j < 1000} {incr j} {
66
+ set index [randomInt 100]
67
+ set buf [r get bigpayload_$index]
68
+ if {$buf != $payload($index)} {
69
+ set err "Values differ: I set '$payload($index)' but I read back '$buf'"
70
+ break
71
+ }
72
+ }
73
+ unset payload
74
+ set _ $err
75
+ } {}
76
+
77
+ test {SET 10000 numeric keys and access all them in reverse order} {
78
+ set err {}
79
+ for {set x 0} {$x < 10000} {incr x} {
80
+ r set $x $x
81
+ }
82
+ set sum 0
83
+ for {set x 9999} {$x >= 0} {incr x -1} {
84
+ set val [r get $x]
85
+ if {$val ne $x} {
86
+ set err "Eleemnt at position $x is $val instead of $x"
87
+ break
88
+ }
89
+ }
90
+ set _ $err
91
+ } {}
92
+
93
+ test {DBSIZE should be 10101 now} {
94
+ r dbsize
95
+ } {10101}
96
+ }
97
+
98
+ test {INCR against non existing key} {
99
+ set res {}
100
+ append res [r incr novar]
101
+ append res [r get novar]
102
+ } {11}
103
+
104
+ test {INCR against key created by incr itself} {
105
+ r incr novar
106
+ } {2}
107
+
108
+ test {INCR against key originally set with SET} {
109
+ r set novar 100
110
+ r incr novar
111
+ } {101}
112
+
113
+ test {INCR over 32bit value} {
114
+ r set novar 17179869184
115
+ r incr novar
116
+ } {17179869185}
117
+
118
+ test {INCRBY over 32bit value with over 32bit increment} {
119
+ r set novar 17179869184
120
+ r incrby novar 17179869184
121
+ } {34359738368}
122
+
123
+ test {INCR fails against key with spaces (no integer encoded)} {
124
+ r set novar " 11 "
125
+ catch {r incr novar} err
126
+ format $err
127
+ } {ERR*}
128
+
129
+ test {INCR fails against a key holding a list} {
130
+ r rpush mylist 1
131
+ catch {r incr mylist} err
132
+ r rpop mylist
133
+ format $err
134
+ } {ERR*}
135
+
136
+ test {DECRBY over 32bit value with over 32bit increment, negative res} {
137
+ r set novar 17179869184
138
+ r decrby novar 17179869185
139
+ } {-1}
140
+
141
+ test "SETNX target key missing" {
142
+ r del novar
143
+ assert_equal 1 [r setnx novar foobared]
144
+ assert_equal "foobared" [r get novar]
145
+ }
146
+
147
+ test "SETNX target key exists" {
148
+ r set novar foobared
149
+ assert_equal 0 [r setnx novar blabla]
150
+ assert_equal "foobared" [r get novar]
151
+ }
152
+
153
+ test "SETNX against not-expired volatile key" {
154
+ r set x 10
155
+ r expire x 10000
156
+ assert_equal 0 [r setnx x 20]
157
+ assert_equal 10 [r get x]
158
+ }
159
+
160
+ test "SETNX against expired volatile key" {
161
+ # Make it very unlikely for the key this test uses to be expired by the
162
+ # active expiry cycle. This is tightly coupled to the implementation of
163
+ # active expiry and dbAdd() but currently the only way to test that
164
+ # SETNX expires a key when it should have been.
165
+ for {set x 0} {$x < 9999} {incr x} {
166
+ r setex key-$x 3600 value
167
+ }
168
+
169
+ # This will be one of 10000 expiring keys. A cycle is executed every
170
+ # 100ms, sampling 10 keys for being expired or not. This key will be
171
+ # expired for at most 1s when we wait 2s, resulting in a total sample
172
+ # of 100 keys. The probability of the success of this test being a
173
+ # false positive is therefore approx. 1%.
174
+ r set x 10
175
+ r expire x 1
176
+
177
+ # Wait for the key to expire
178
+ after 2000
179
+
180
+ assert_equal 1 [r setnx x 20]
181
+ assert_equal 20 [r get x]
182
+ }
183
+
184
+ test {EXISTS} {
185
+ set res {}
186
+ r set newkey test
187
+ append res [r exists newkey]
188
+ r del newkey
189
+ append res [r exists newkey]
190
+ } {10}
191
+
192
+ test {Zero length value in key. SET/GET/EXISTS} {
193
+ r set emptykey {}
194
+ set res [r get emptykey]
195
+ append res [r exists emptykey]
196
+ r del emptykey
197
+ append res [r exists emptykey]
198
+ } {10}
199
+
200
+ test {Commands pipelining} {
201
+ set fd [r channel]
202
+ puts -nonewline $fd "SET k1 xyzk\r\nGET k1\r\nPING\r\n"
203
+ flush $fd
204
+ set res {}
205
+ append res [string match OK* [::redis::redis_read_reply $fd]]
206
+ append res [::redis::redis_read_reply $fd]
207
+ append res [string match PONG* [::redis::redis_read_reply $fd]]
208
+ format $res
209
+ } {1xyzk1}
210
+
211
+ test {Non existing command} {
212
+ catch {r foobaredcommand} err
213
+ string match ERR* $err
214
+ } {1}
215
+
216
+ test {RENAME basic usage} {
217
+ r set mykey hello
218
+ r rename mykey mykey1
219
+ r rename mykey1 mykey2
220
+ r get mykey2
221
+ } {hello}
222
+
223
+ test {RENAME source key should no longer exist} {
224
+ r exists mykey
225
+ } {0}
226
+
227
+ test {RENAME against already existing key} {
228
+ r set mykey a
229
+ r set mykey2 b
230
+ r rename mykey2 mykey
231
+ set res [r get mykey]
232
+ append res [r exists mykey2]
233
+ } {b0}
234
+
235
+ test {RENAMENX basic usage} {
236
+ r del mykey
237
+ r del mykey2
238
+ r set mykey foobar
239
+ r renamenx mykey mykey2
240
+ set res [r get mykey2]
241
+ append res [r exists mykey]
242
+ } {foobar0}
243
+
244
+ test {RENAMENX against already existing key} {
245
+ r set mykey foo
246
+ r set mykey2 bar
247
+ r renamenx mykey mykey2
248
+ } {0}
249
+
250
+ test {RENAMENX against already existing key (2)} {
251
+ set res [r get mykey]
252
+ append res [r get mykey2]
253
+ } {foobar}
254
+
255
+ test {RENAME against non existing source key} {
256
+ catch {r rename nokey foobar} err
257
+ format $err
258
+ } {ERR*}
259
+
260
+ test {RENAME where source and dest key is the same} {
261
+ catch {r rename mykey mykey} err
262
+ format $err
263
+ } {ERR*}
264
+
265
+ test {DEL all keys again (DB 0)} {
266
+ foreach key [r keys *] {
267
+ r del $key
268
+ }
269
+ r dbsize
270
+ } {0}
271
+
272
+ test {DEL all keys again (DB 1)} {
273
+ r select 10
274
+ foreach key [r keys *] {
275
+ r del $key
276
+ }
277
+ set res [r dbsize]
278
+ r select 9
279
+ format $res
280
+ } {0}
281
+
282
+ test {MOVE basic usage} {
283
+ r set mykey foobar
284
+ r move mykey 10
285
+ set res {}
286
+ lappend res [r exists mykey]
287
+ lappend res [r dbsize]
288
+ r select 10
289
+ lappend res [r get mykey]
290
+ lappend res [r dbsize]
291
+ r select 9
292
+ format $res
293
+ } [list 0 0 foobar 1]
294
+
295
+ test {MOVE against key existing in the target DB} {
296
+ r set mykey hello
297
+ r move mykey 10
298
+ } {0}
299
+
300
+ test {SET/GET keys in different DBs} {
301
+ r set a hello
302
+ r set b world
303
+ r select 10
304
+ r set a foo
305
+ r set b bared
306
+ r select 9
307
+ set res {}
308
+ lappend res [r get a]
309
+ lappend res [r get b]
310
+ r select 10
311
+ lappend res [r get a]
312
+ lappend res [r get b]
313
+ r select 9
314
+ format $res
315
+ } {hello world foo bared}
316
+
317
+ test {MGET} {
318
+ r flushdb
319
+ r set foo BAR
320
+ r set bar FOO
321
+ r mget foo bar
322
+ } {BAR FOO}
323
+
324
+ test {MGET against non existing key} {
325
+ r mget foo baazz bar
326
+ } {BAR {} FOO}
327
+
328
+ test {MGET against non-string key} {
329
+ r sadd myset ciao
330
+ r sadd myset bau
331
+ r mget foo baazz bar myset
332
+ } {BAR {} FOO {}}
333
+
334
+ test {RANDOMKEY} {
335
+ r flushdb
336
+ r set foo x
337
+ r set bar y
338
+ set foo_seen 0
339
+ set bar_seen 0
340
+ for {set i 0} {$i < 100} {incr i} {
341
+ set rkey [r randomkey]
342
+ if {$rkey eq {foo}} {
343
+ set foo_seen 1
344
+ }
345
+ if {$rkey eq {bar}} {
346
+ set bar_seen 1
347
+ }
348
+ }
349
+ list $foo_seen $bar_seen
350
+ } {1 1}
351
+
352
+ test {RANDOMKEY against empty DB} {
353
+ r flushdb
354
+ r randomkey
355
+ } {}
356
+
357
+ test {RANDOMKEY regression 1} {
358
+ r flushdb
359
+ r set x 10
360
+ r del x
361
+ r randomkey
362
+ } {}
363
+
364
+ test {GETSET (set new value)} {
365
+ list [r getset foo xyz] [r get foo]
366
+ } {{} xyz}
367
+
368
+ test {GETSET (replace old value)} {
369
+ r set foo bar
370
+ list [r getset foo xyz] [r get foo]
371
+ } {bar xyz}
372
+
373
+ test {MSET base case} {
374
+ r mset x 10 y "foo bar" z "x x x x x x x\n\n\r\n"
375
+ r mget x y z
376
+ } [list 10 {foo bar} "x x x x x x x\n\n\r\n"]
377
+
378
+ test {MSET wrong number of args} {
379
+ catch {r mset x 10 y "foo bar" z} err
380
+ format $err
381
+ } {*wrong number*}
382
+
383
+ test {MSETNX with already existent key} {
384
+ list [r msetnx x1 xxx y2 yyy x 20] [r exists x1] [r exists y2]
385
+ } {0 0 0}
386
+
387
+ test {MSETNX with not existing keys} {
388
+ list [r msetnx x1 xxx y2 yyy] [r get x1] [r get y2]
389
+ } {1 xxx yyy}
390
+
391
+ test "STRLEN against non-existing key" {
392
+ assert_equal 0 [r strlen notakey]
393
+ }
394
+
395
+ test "STRLEN against integer-encoded value" {
396
+ r set myinteger -555
397
+ assert_equal 4 [r strlen myinteger]
398
+ }
399
+
400
+ test "STRLEN against plain string" {
401
+ r set mystring "foozzz0123456789 baz"
402
+ assert_equal 20 [r strlen mystring]
403
+ }
404
+
405
+ test "SETBIT against non-existing key" {
406
+ r del mykey
407
+ assert_equal 0 [r setbit mykey 1 1]
408
+ assert_equal [binary format B* 01000000] [r get mykey]
409
+ }
410
+
411
+ test "SETBIT against string-encoded key" {
412
+ # Ascii "@" is integer 64 = 01 00 00 00
413
+ r set mykey "@"
414
+
415
+ assert_equal 0 [r setbit mykey 2 1]
416
+ assert_equal [binary format B* 01100000] [r get mykey]
417
+ assert_equal 1 [r setbit mykey 1 0]
418
+ assert_equal [binary format B* 00100000] [r get mykey]
419
+ }
420
+
421
+ test "SETBIT against integer-encoded key" {
422
+ # Ascii "1" is integer 49 = 00 11 00 01
423
+ r set mykey 1
424
+ assert_encoding int mykey
425
+
426
+ assert_equal 0 [r setbit mykey 6 1]
427
+ assert_equal [binary format B* 00110011] [r get mykey]
428
+ assert_equal 1 [r setbit mykey 2 0]
429
+ assert_equal [binary format B* 00010011] [r get mykey]
430
+ }
431
+
432
+ test "SETBIT against key with wrong type" {
433
+ r del mykey
434
+ r lpush mykey "foo"
435
+ assert_error "*wrong kind*" {r setbit mykey 0 1}
436
+ }
437
+
438
+ test "SETBIT with out of range bit offset" {
439
+ r del mykey
440
+ assert_error "*out of range*" {r setbit mykey [expr 4*1024*1024*1024] 1}
441
+ assert_error "*out of range*" {r setbit mykey -1 1}
442
+ }
443
+
444
+ test "SETBIT with non-bit argument" {
445
+ r del mykey
446
+ assert_error "*out of range*" {r setbit mykey 0 -1}
447
+ assert_error "*out of range*" {r setbit mykey 0 2}
448
+ assert_error "*out of range*" {r setbit mykey 0 10}
449
+ assert_error "*out of range*" {r setbit mykey 0 20}
450
+ }
451
+
452
+ test "SETBIT fuzzing" {
453
+ set str ""
454
+ set len [expr 256*8]
455
+ r del mykey
456
+
457
+ for {set i 0} {$i < 2000} {incr i} {
458
+ set bitnum [randomInt $len]
459
+ set bitval [randomInt 2]
460
+ set fmt [format "%%-%ds%%d%%-s" $bitnum]
461
+ set head [string range $str 0 $bitnum-1]
462
+ set tail [string range $str $bitnum+1 end]
463
+ set str [string map {" " 0} [format $fmt $head $bitval $tail]]
464
+
465
+ r setbit mykey $bitnum $bitval
466
+ assert_equal [binary format B* $str] [r get mykey]
467
+ }
468
+ }
469
+
470
+ test "GETBIT against non-existing key" {
471
+ r del mykey
472
+ assert_equal 0 [r getbit mykey 0]
473
+ }
474
+
475
+ test "GETBIT against string-encoded key" {
476
+ # Single byte with 2nd and 3rd bit set
477
+ r set mykey "`"
478
+
479
+ # In-range
480
+ assert_equal 0 [r getbit mykey 0]
481
+ assert_equal 1 [r getbit mykey 1]
482
+ assert_equal 1 [r getbit mykey 2]
483
+ assert_equal 0 [r getbit mykey 3]
484
+
485
+ # Out-range
486
+ assert_equal 0 [r getbit mykey 8]
487
+ assert_equal 0 [r getbit mykey 100]
488
+ assert_equal 0 [r getbit mykey 10000]
489
+ }
490
+
491
+ test "GETBIT against integer-encoded key" {
492
+ r set mykey 1
493
+ assert_encoding int mykey
494
+
495
+ # Ascii "1" is integer 49 = 00 11 00 01
496
+ assert_equal 0 [r getbit mykey 0]
497
+ assert_equal 0 [r getbit mykey 1]
498
+ assert_equal 1 [r getbit mykey 2]
499
+ assert_equal 1 [r getbit mykey 3]
500
+
501
+ # Out-range
502
+ assert_equal 0 [r getbit mykey 8]
503
+ assert_equal 0 [r getbit mykey 100]
504
+ assert_equal 0 [r getbit mykey 10000]
505
+ }
506
+
507
+ test "SETRANGE against non-existing key" {
508
+ r del mykey
509
+ assert_equal 3 [r setrange mykey 0 foo]
510
+ assert_equal "foo" [r get mykey]
511
+
512
+ r del mykey
513
+ assert_equal 0 [r setrange mykey 0 ""]
514
+ assert_equal 0 [r exists mykey]
515
+
516
+ r del mykey
517
+ assert_equal 4 [r setrange mykey 1 foo]
518
+ assert_equal "\000foo" [r get mykey]
519
+ }
520
+
521
+ test "SETRANGE against string-encoded key" {
522
+ r set mykey "foo"
523
+ assert_equal 3 [r setrange mykey 0 b]
524
+ assert_equal "boo" [r get mykey]
525
+
526
+ r set mykey "foo"
527
+ assert_equal 3 [r setrange mykey 0 ""]
528
+ assert_equal "foo" [r get mykey]
529
+
530
+ r set mykey "foo"
531
+ assert_equal 3 [r setrange mykey 1 b]
532
+ assert_equal "fbo" [r get mykey]
533
+
534
+ r set mykey "foo"
535
+ assert_equal 7 [r setrange mykey 4 bar]
536
+ assert_equal "foo\000bar" [r get mykey]
537
+ }
538
+
539
+ test "SETRANGE against integer-encoded key" {
540
+ r set mykey 1234
541
+ assert_encoding int mykey
542
+ assert_equal 4 [r setrange mykey 0 2]
543
+ assert_encoding raw mykey
544
+ assert_equal 2234 [r get mykey]
545
+
546
+ # Shouldn't change encoding when nothing is set
547
+ r set mykey 1234
548
+ assert_encoding int mykey
549
+ assert_equal 4 [r setrange mykey 0 ""]
550
+ assert_encoding int mykey
551
+ assert_equal 1234 [r get mykey]
552
+
553
+ r set mykey 1234
554
+ assert_encoding int mykey
555
+ assert_equal 4 [r setrange mykey 1 3]
556
+ assert_encoding raw mykey
557
+ assert_equal 1334 [r get mykey]
558
+
559
+ r set mykey 1234
560
+ assert_encoding int mykey
561
+ assert_equal 6 [r setrange mykey 5 2]
562
+ assert_encoding raw mykey
563
+ assert_equal "1234\0002" [r get mykey]
564
+ }
565
+
566
+ test "SETRANGE against key with wrong type" {
567
+ r del mykey
568
+ r lpush mykey "foo"
569
+ assert_error "*wrong kind*" {r setrange mykey 0 bar}
570
+ }
571
+
572
+ test "SETRANGE with out of range offset" {
573
+ r del mykey
574
+ assert_error "*maximum allowed size*" {r setrange mykey [expr 512*1024*1024-4] world}
575
+
576
+ r set mykey "hello"
577
+ assert_error "*out of range*" {r setrange mykey -1 world}
578
+ assert_error "*maximum allowed size*" {r setrange mykey [expr 512*1024*1024-4] world}
579
+ }
580
+
581
+ test "GETRANGE against non-existing key" {
582
+ r del mykey
583
+ assert_equal "" [r getrange mykey 0 -1]
584
+ }
585
+
586
+ test "GETRANGE against string value" {
587
+ r set mykey "Hello World"
588
+ assert_equal "Hell" [r getrange mykey 0 3]
589
+ assert_equal "Hello World" [r getrange mykey 0 -1]
590
+ assert_equal "orld" [r getrange mykey -4 -1]
591
+ assert_equal "" [r getrange mykey 5 3]
592
+ assert_equal " World" [r getrange mykey 5 5000]
593
+ assert_equal "Hello World" [r getrange mykey -5000 10000]
594
+ }
595
+
596
+ test "GETRANGE against integer-encoded value" {
597
+ r set mykey 1234
598
+ assert_equal "123" [r getrange mykey 0 2]
599
+ assert_equal "1234" [r getrange mykey 0 -1]
600
+ assert_equal "234" [r getrange mykey -3 -1]
601
+ assert_equal "" [r getrange mykey 5 3]
602
+ assert_equal "4" [r getrange mykey 3 5000]
603
+ assert_equal "1234" [r getrange mykey -5000 10000]
604
+ }
605
+
606
+ test "GETRANGE fuzzing" {
607
+ for {set i 0} {$i < 1000} {incr i} {
608
+ r set bin [set bin [randstring 0 1024 binary]]
609
+ set _start [set start [randomInt 1500]]
610
+ set _end [set end [randomInt 1500]]
611
+ if {$_start < 0} {set _start "end-[abs($_start)-1]"}
612
+ if {$_end < 0} {set _end "end-[abs($_end)-1]"}
613
+ assert_equal [string range $bin $_start $_end] [r getrange bin $start $end]
614
+ }
615
+ }
616
+ }