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,197 @@
|
|
1
|
+
/* The following is the NetBSD libc qsort implementation modified in order to
|
2
|
+
* support partial sorting of ranges for Redis.
|
3
|
+
*
|
4
|
+
* Copyright(C) 2009-2010 Salvatore Sanfilippo. All rights reserved.
|
5
|
+
*
|
6
|
+
* The original copyright notice follows. */
|
7
|
+
|
8
|
+
|
9
|
+
/* $NetBSD: qsort.c,v 1.19 2009/01/30 23:38:44 lukem Exp $ */
|
10
|
+
|
11
|
+
/*-
|
12
|
+
* Copyright (c) 1992, 1993
|
13
|
+
* The Regents of the University of California. All rights reserved.
|
14
|
+
*
|
15
|
+
* Redistribution and use in source and binary forms, with or without
|
16
|
+
* modification, are permitted provided that the following conditions
|
17
|
+
* are met:
|
18
|
+
* 1. Redistributions of source code must retain the above copyright
|
19
|
+
* notice, this list of conditions and the following disclaimer.
|
20
|
+
* 2. Redistributions in binary form must reproduce the above copyright
|
21
|
+
* notice, this list of conditions and the following disclaimer in the
|
22
|
+
* documentation and/or other materials provided with the distribution.
|
23
|
+
* 3. Neither the name of the University nor the names of its contributors
|
24
|
+
* may be used to endorse or promote products derived from this software
|
25
|
+
* without specific prior written permission.
|
26
|
+
*
|
27
|
+
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
28
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
29
|
+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
30
|
+
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
31
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
32
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
33
|
+
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
34
|
+
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
35
|
+
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
36
|
+
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
37
|
+
* SUCH DAMAGE.
|
38
|
+
*/
|
39
|
+
|
40
|
+
#include <sys/types.h>
|
41
|
+
|
42
|
+
#include <assert.h>
|
43
|
+
#include <errno.h>
|
44
|
+
#include <stdlib.h>
|
45
|
+
|
46
|
+
static inline char *med3 (char *, char *, char *,
|
47
|
+
int (*)(const void *, const void *));
|
48
|
+
static inline void swapfunc (char *, char *, size_t, int);
|
49
|
+
|
50
|
+
#define min(a, b) (a) < (b) ? a : b
|
51
|
+
|
52
|
+
/*
|
53
|
+
* Qsort routine from Bentley & McIlroy's "Engineering a Sort Function".
|
54
|
+
*/
|
55
|
+
#define swapcode(TYPE, parmi, parmj, n) { \
|
56
|
+
size_t i = (n) / sizeof (TYPE); \
|
57
|
+
TYPE *pi = (TYPE *)(void *)(parmi); \
|
58
|
+
TYPE *pj = (TYPE *)(void *)(parmj); \
|
59
|
+
do { \
|
60
|
+
TYPE t = *pi; \
|
61
|
+
*pi++ = *pj; \
|
62
|
+
*pj++ = t; \
|
63
|
+
} while (--i > 0); \
|
64
|
+
}
|
65
|
+
|
66
|
+
#define SWAPINIT(a, es) swaptype = ((char *)a - (char *)0) % sizeof(long) || \
|
67
|
+
es % sizeof(long) ? 2 : es == sizeof(long)? 0 : 1;
|
68
|
+
|
69
|
+
static inline void
|
70
|
+
swapfunc(char *a, char *b, size_t n, int swaptype)
|
71
|
+
{
|
72
|
+
|
73
|
+
if (swaptype <= 1)
|
74
|
+
swapcode(long, a, b, n)
|
75
|
+
else
|
76
|
+
swapcode(char, a, b, n)
|
77
|
+
}
|
78
|
+
|
79
|
+
#define swap(a, b) \
|
80
|
+
if (swaptype == 0) { \
|
81
|
+
long t = *(long *)(void *)(a); \
|
82
|
+
*(long *)(void *)(a) = *(long *)(void *)(b); \
|
83
|
+
*(long *)(void *)(b) = t; \
|
84
|
+
} else \
|
85
|
+
swapfunc(a, b, es, swaptype)
|
86
|
+
|
87
|
+
#define vecswap(a, b, n) if ((n) > 0) swapfunc((a), (b), (size_t)(n), swaptype)
|
88
|
+
|
89
|
+
static inline char *
|
90
|
+
med3(char *a, char *b, char *c,
|
91
|
+
int (*cmp) (const void *, const void *))
|
92
|
+
{
|
93
|
+
|
94
|
+
return cmp(a, b) < 0 ?
|
95
|
+
(cmp(b, c) < 0 ? b : (cmp(a, c) < 0 ? c : a ))
|
96
|
+
:(cmp(b, c) > 0 ? b : (cmp(a, c) < 0 ? a : c ));
|
97
|
+
}
|
98
|
+
|
99
|
+
static void
|
100
|
+
_pqsort(void *a, size_t n, size_t es,
|
101
|
+
int (*cmp) (const void *, const void *), void *lrange, void *rrange)
|
102
|
+
{
|
103
|
+
char *pa, *pb, *pc, *pd, *pl, *pm, *pn;
|
104
|
+
size_t d, r;
|
105
|
+
int swaptype, swap_cnt, cmp_result;
|
106
|
+
|
107
|
+
loop: SWAPINIT(a, es);
|
108
|
+
swap_cnt = 0;
|
109
|
+
if (n < 7) {
|
110
|
+
for (pm = (char *) a + es; pm < (char *) a + n * es; pm += es)
|
111
|
+
for (pl = pm; pl > (char *) a && cmp(pl - es, pl) > 0;
|
112
|
+
pl -= es)
|
113
|
+
swap(pl, pl - es);
|
114
|
+
return;
|
115
|
+
}
|
116
|
+
pm = (char *) a + (n / 2) * es;
|
117
|
+
if (n > 7) {
|
118
|
+
pl = (char *) a;
|
119
|
+
pn = (char *) a + (n - 1) * es;
|
120
|
+
if (n > 40) {
|
121
|
+
d = (n / 8) * es;
|
122
|
+
pl = med3(pl, pl + d, pl + 2 * d, cmp);
|
123
|
+
pm = med3(pm - d, pm, pm + d, cmp);
|
124
|
+
pn = med3(pn - 2 * d, pn - d, pn, cmp);
|
125
|
+
}
|
126
|
+
pm = med3(pl, pm, pn, cmp);
|
127
|
+
}
|
128
|
+
swap(a, pm);
|
129
|
+
pa = pb = (char *) a + es;
|
130
|
+
|
131
|
+
pc = pd = (char *) a + (n - 1) * es;
|
132
|
+
for (;;) {
|
133
|
+
while (pb <= pc && (cmp_result = cmp(pb, a)) <= 0) {
|
134
|
+
if (cmp_result == 0) {
|
135
|
+
swap_cnt = 1;
|
136
|
+
swap(pa, pb);
|
137
|
+
pa += es;
|
138
|
+
}
|
139
|
+
pb += es;
|
140
|
+
}
|
141
|
+
while (pb <= pc && (cmp_result = cmp(pc, a)) >= 0) {
|
142
|
+
if (cmp_result == 0) {
|
143
|
+
swap_cnt = 1;
|
144
|
+
swap(pc, pd);
|
145
|
+
pd -= es;
|
146
|
+
}
|
147
|
+
pc -= es;
|
148
|
+
}
|
149
|
+
if (pb > pc)
|
150
|
+
break;
|
151
|
+
swap(pb, pc);
|
152
|
+
swap_cnt = 1;
|
153
|
+
pb += es;
|
154
|
+
pc -= es;
|
155
|
+
}
|
156
|
+
if (swap_cnt == 0) { /* Switch to insertion sort */
|
157
|
+
for (pm = (char *) a + es; pm < (char *) a + n * es; pm += es)
|
158
|
+
for (pl = pm; pl > (char *) a && cmp(pl - es, pl) > 0;
|
159
|
+
pl -= es)
|
160
|
+
swap(pl, pl - es);
|
161
|
+
return;
|
162
|
+
}
|
163
|
+
|
164
|
+
pn = (char *) a + n * es;
|
165
|
+
r = min(pa - (char *) a, pb - pa);
|
166
|
+
vecswap(a, pb - r, r);
|
167
|
+
r = min((size_t)(pd - pc), pn - pd - es);
|
168
|
+
vecswap(pb, pn - r, r);
|
169
|
+
if ((r = pb - pa) > es) {
|
170
|
+
void *_l = a, *_r = ((unsigned char*)a)+r-1;
|
171
|
+
if (!((lrange < _l && rrange < _l) ||
|
172
|
+
(lrange > _r && rrange > _r)))
|
173
|
+
_pqsort(a, r / es, es, cmp, lrange, rrange);
|
174
|
+
}
|
175
|
+
if ((r = pd - pc) > es) {
|
176
|
+
void *_l, *_r;
|
177
|
+
|
178
|
+
/* Iterate rather than recurse to save stack space */
|
179
|
+
a = pn - r;
|
180
|
+
n = r / es;
|
181
|
+
|
182
|
+
_l = a;
|
183
|
+
_r = ((unsigned char*)a)+r-1;
|
184
|
+
if (!((lrange < _l && rrange < _l) ||
|
185
|
+
(lrange > _r && rrange > _r)))
|
186
|
+
goto loop;
|
187
|
+
}
|
188
|
+
/* qsort(pn - r, r / es, es, cmp);*/
|
189
|
+
}
|
190
|
+
|
191
|
+
void
|
192
|
+
pqsort(void *a, size_t n, size_t es,
|
193
|
+
int (*cmp) (const void *, const void *), size_t lrange, size_t rrange)
|
194
|
+
{
|
195
|
+
_pqsort(a,n,es,cmp,((unsigned char*)a)+(lrange*es),
|
196
|
+
((unsigned char*)a)+((rrange+1)*es)-1);
|
197
|
+
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/* The following is the NetBSD libc qsort implementation modified in order to
|
2
|
+
* support partial sorting of ranges for Redis.
|
3
|
+
*
|
4
|
+
* Copyright(C) 2009-2010 Salvatore Sanfilippo. All rights reserved.
|
5
|
+
*
|
6
|
+
* See the pqsort.c file for the original copyright notice. */
|
7
|
+
|
8
|
+
#ifndef __PQSORT_H
|
9
|
+
#define __PQSORT_H
|
10
|
+
|
11
|
+
void
|
12
|
+
pqsort(void *a, size_t n, size_t es,
|
13
|
+
int (*cmp) (const void *, const void *), size_t lrange, size_t rrange);
|
14
|
+
|
15
|
+
#endif
|
@@ -0,0 +1,267 @@
|
|
1
|
+
#include "redis.h"
|
2
|
+
|
3
|
+
/*-----------------------------------------------------------------------------
|
4
|
+
* Pubsub low level API
|
5
|
+
*----------------------------------------------------------------------------*/
|
6
|
+
|
7
|
+
void freePubsubPattern(void *p) {
|
8
|
+
pubsubPattern *pat = p;
|
9
|
+
|
10
|
+
decrRefCount(pat->pattern);
|
11
|
+
zfree(pat);
|
12
|
+
}
|
13
|
+
|
14
|
+
int listMatchPubsubPattern(void *a, void *b) {
|
15
|
+
pubsubPattern *pa = a, *pb = b;
|
16
|
+
|
17
|
+
return (pa->client == pb->client) &&
|
18
|
+
(equalStringObjects(pa->pattern,pb->pattern));
|
19
|
+
}
|
20
|
+
|
21
|
+
/* Subscribe a client to a channel. Returns 1 if the operation succeeded, or
|
22
|
+
* 0 if the client was already subscribed to that channel. */
|
23
|
+
int pubsubSubscribeChannel(redisClient *c, robj *channel) {
|
24
|
+
struct dictEntry *de;
|
25
|
+
list *clients = NULL;
|
26
|
+
int retval = 0;
|
27
|
+
|
28
|
+
/* Add the channel to the client -> channels hash table */
|
29
|
+
if (dictAdd(c->pubsub_channels,channel,NULL) == DICT_OK) {
|
30
|
+
retval = 1;
|
31
|
+
incrRefCount(channel);
|
32
|
+
/* Add the client to the channel -> list of clients hash table */
|
33
|
+
de = dictFind(server.pubsub_channels,channel);
|
34
|
+
if (de == NULL) {
|
35
|
+
clients = listCreate();
|
36
|
+
dictAdd(server.pubsub_channels,channel,clients);
|
37
|
+
incrRefCount(channel);
|
38
|
+
} else {
|
39
|
+
clients = dictGetEntryVal(de);
|
40
|
+
}
|
41
|
+
listAddNodeTail(clients,c);
|
42
|
+
}
|
43
|
+
/* Notify the client */
|
44
|
+
addReply(c,shared.mbulk3);
|
45
|
+
addReply(c,shared.subscribebulk);
|
46
|
+
addReplyBulk(c,channel);
|
47
|
+
addReplyLongLong(c,dictSize(c->pubsub_channels)+listLength(c->pubsub_patterns));
|
48
|
+
return retval;
|
49
|
+
}
|
50
|
+
|
51
|
+
/* Unsubscribe a client from a channel. Returns 1 if the operation succeeded, or
|
52
|
+
* 0 if the client was not subscribed to the specified channel. */
|
53
|
+
int pubsubUnsubscribeChannel(redisClient *c, robj *channel, int notify) {
|
54
|
+
struct dictEntry *de;
|
55
|
+
list *clients;
|
56
|
+
listNode *ln;
|
57
|
+
int retval = 0;
|
58
|
+
|
59
|
+
/* Remove the channel from the client -> channels hash table */
|
60
|
+
incrRefCount(channel); /* channel may be just a pointer to the same object
|
61
|
+
we have in the hash tables. Protect it... */
|
62
|
+
if (dictDelete(c->pubsub_channels,channel) == DICT_OK) {
|
63
|
+
retval = 1;
|
64
|
+
/* Remove the client from the channel -> clients list hash table */
|
65
|
+
de = dictFind(server.pubsub_channels,channel);
|
66
|
+
redisAssert(de != NULL);
|
67
|
+
clients = dictGetEntryVal(de);
|
68
|
+
ln = listSearchKey(clients,c);
|
69
|
+
redisAssert(ln != NULL);
|
70
|
+
listDelNode(clients,ln);
|
71
|
+
if (listLength(clients) == 0) {
|
72
|
+
/* Free the list and associated hash entry at all if this was
|
73
|
+
* the latest client, so that it will be possible to abuse
|
74
|
+
* Redis PUBSUB creating millions of channels. */
|
75
|
+
dictDelete(server.pubsub_channels,channel);
|
76
|
+
}
|
77
|
+
}
|
78
|
+
/* Notify the client */
|
79
|
+
if (notify) {
|
80
|
+
addReply(c,shared.mbulk3);
|
81
|
+
addReply(c,shared.unsubscribebulk);
|
82
|
+
addReplyBulk(c,channel);
|
83
|
+
addReplyLongLong(c,dictSize(c->pubsub_channels)+
|
84
|
+
listLength(c->pubsub_patterns));
|
85
|
+
|
86
|
+
}
|
87
|
+
decrRefCount(channel); /* it is finally safe to release it */
|
88
|
+
return retval;
|
89
|
+
}
|
90
|
+
|
91
|
+
/* Subscribe a client to a pattern. Returns 1 if the operation succeeded, or 0 if the clinet was already subscribed to that pattern. */
|
92
|
+
int pubsubSubscribePattern(redisClient *c, robj *pattern) {
|
93
|
+
int retval = 0;
|
94
|
+
|
95
|
+
if (listSearchKey(c->pubsub_patterns,pattern) == NULL) {
|
96
|
+
retval = 1;
|
97
|
+
pubsubPattern *pat;
|
98
|
+
listAddNodeTail(c->pubsub_patterns,pattern);
|
99
|
+
incrRefCount(pattern);
|
100
|
+
pat = zmalloc(sizeof(*pat));
|
101
|
+
pat->pattern = getDecodedObject(pattern);
|
102
|
+
pat->client = c;
|
103
|
+
listAddNodeTail(server.pubsub_patterns,pat);
|
104
|
+
}
|
105
|
+
/* Notify the client */
|
106
|
+
addReply(c,shared.mbulk3);
|
107
|
+
addReply(c,shared.psubscribebulk);
|
108
|
+
addReplyBulk(c,pattern);
|
109
|
+
addReplyLongLong(c,dictSize(c->pubsub_channels)+listLength(c->pubsub_patterns));
|
110
|
+
return retval;
|
111
|
+
}
|
112
|
+
|
113
|
+
/* Unsubscribe a client from a channel. Returns 1 if the operation succeeded, or
|
114
|
+
* 0 if the client was not subscribed to the specified channel. */
|
115
|
+
int pubsubUnsubscribePattern(redisClient *c, robj *pattern, int notify) {
|
116
|
+
listNode *ln;
|
117
|
+
pubsubPattern pat;
|
118
|
+
int retval = 0;
|
119
|
+
|
120
|
+
incrRefCount(pattern); /* Protect the object. May be the same we remove */
|
121
|
+
if ((ln = listSearchKey(c->pubsub_patterns,pattern)) != NULL) {
|
122
|
+
retval = 1;
|
123
|
+
listDelNode(c->pubsub_patterns,ln);
|
124
|
+
pat.client = c;
|
125
|
+
pat.pattern = pattern;
|
126
|
+
ln = listSearchKey(server.pubsub_patterns,&pat);
|
127
|
+
listDelNode(server.pubsub_patterns,ln);
|
128
|
+
}
|
129
|
+
/* Notify the client */
|
130
|
+
if (notify) {
|
131
|
+
addReply(c,shared.mbulk3);
|
132
|
+
addReply(c,shared.punsubscribebulk);
|
133
|
+
addReplyBulk(c,pattern);
|
134
|
+
addReplyLongLong(c,dictSize(c->pubsub_channels)+
|
135
|
+
listLength(c->pubsub_patterns));
|
136
|
+
}
|
137
|
+
decrRefCount(pattern);
|
138
|
+
return retval;
|
139
|
+
}
|
140
|
+
|
141
|
+
/* Unsubscribe from all the channels. Return the number of channels the
|
142
|
+
* client was subscribed from. */
|
143
|
+
int pubsubUnsubscribeAllChannels(redisClient *c, int notify) {
|
144
|
+
dictIterator *di = dictGetSafeIterator(c->pubsub_channels);
|
145
|
+
dictEntry *de;
|
146
|
+
int count = 0;
|
147
|
+
|
148
|
+
while((de = dictNext(di)) != NULL) {
|
149
|
+
robj *channel = dictGetEntryKey(de);
|
150
|
+
|
151
|
+
count += pubsubUnsubscribeChannel(c,channel,notify);
|
152
|
+
}
|
153
|
+
dictReleaseIterator(di);
|
154
|
+
return count;
|
155
|
+
}
|
156
|
+
|
157
|
+
/* Unsubscribe from all the patterns. Return the number of patterns the
|
158
|
+
* client was subscribed from. */
|
159
|
+
int pubsubUnsubscribeAllPatterns(redisClient *c, int notify) {
|
160
|
+
listNode *ln;
|
161
|
+
listIter li;
|
162
|
+
int count = 0;
|
163
|
+
|
164
|
+
listRewind(c->pubsub_patterns,&li);
|
165
|
+
while ((ln = listNext(&li)) != NULL) {
|
166
|
+
robj *pattern = ln->value;
|
167
|
+
|
168
|
+
count += pubsubUnsubscribePattern(c,pattern,notify);
|
169
|
+
}
|
170
|
+
return count;
|
171
|
+
}
|
172
|
+
|
173
|
+
/* Publish a message */
|
174
|
+
int pubsubPublishMessage(robj *channel, robj *message) {
|
175
|
+
int receivers = 0;
|
176
|
+
struct dictEntry *de;
|
177
|
+
listNode *ln;
|
178
|
+
listIter li;
|
179
|
+
|
180
|
+
/* Send to clients listening for that channel */
|
181
|
+
de = dictFind(server.pubsub_channels,channel);
|
182
|
+
if (de) {
|
183
|
+
list *list = dictGetEntryVal(de);
|
184
|
+
listNode *ln;
|
185
|
+
listIter li;
|
186
|
+
|
187
|
+
listRewind(list,&li);
|
188
|
+
while ((ln = listNext(&li)) != NULL) {
|
189
|
+
redisClient *c = ln->value;
|
190
|
+
|
191
|
+
addReply(c,shared.mbulk3);
|
192
|
+
addReply(c,shared.messagebulk);
|
193
|
+
addReplyBulk(c,channel);
|
194
|
+
addReplyBulk(c,message);
|
195
|
+
receivers++;
|
196
|
+
}
|
197
|
+
}
|
198
|
+
/* Send to clients listening to matching channels */
|
199
|
+
if (listLength(server.pubsub_patterns)) {
|
200
|
+
listRewind(server.pubsub_patterns,&li);
|
201
|
+
channel = getDecodedObject(channel);
|
202
|
+
while ((ln = listNext(&li)) != NULL) {
|
203
|
+
pubsubPattern *pat = ln->value;
|
204
|
+
|
205
|
+
if (stringmatchlen((char*)pat->pattern->ptr,
|
206
|
+
sdslen(pat->pattern->ptr),
|
207
|
+
(char*)channel->ptr,
|
208
|
+
sdslen(channel->ptr),0)) {
|
209
|
+
addReply(pat->client,shared.mbulk4);
|
210
|
+
addReply(pat->client,shared.pmessagebulk);
|
211
|
+
addReplyBulk(pat->client,pat->pattern);
|
212
|
+
addReplyBulk(pat->client,channel);
|
213
|
+
addReplyBulk(pat->client,message);
|
214
|
+
receivers++;
|
215
|
+
}
|
216
|
+
}
|
217
|
+
decrRefCount(channel);
|
218
|
+
}
|
219
|
+
return receivers;
|
220
|
+
}
|
221
|
+
|
222
|
+
/*-----------------------------------------------------------------------------
|
223
|
+
* Pubsub commands implementation
|
224
|
+
*----------------------------------------------------------------------------*/
|
225
|
+
|
226
|
+
void subscribeCommand(redisClient *c) {
|
227
|
+
int j;
|
228
|
+
|
229
|
+
for (j = 1; j < c->argc; j++)
|
230
|
+
pubsubSubscribeChannel(c,c->argv[j]);
|
231
|
+
}
|
232
|
+
|
233
|
+
void unsubscribeCommand(redisClient *c) {
|
234
|
+
if (c->argc == 1) {
|
235
|
+
pubsubUnsubscribeAllChannels(c,1);
|
236
|
+
return;
|
237
|
+
} else {
|
238
|
+
int j;
|
239
|
+
|
240
|
+
for (j = 1; j < c->argc; j++)
|
241
|
+
pubsubUnsubscribeChannel(c,c->argv[j],1);
|
242
|
+
}
|
243
|
+
}
|
244
|
+
|
245
|
+
void psubscribeCommand(redisClient *c) {
|
246
|
+
int j;
|
247
|
+
|
248
|
+
for (j = 1; j < c->argc; j++)
|
249
|
+
pubsubSubscribePattern(c,c->argv[j]);
|
250
|
+
}
|
251
|
+
|
252
|
+
void punsubscribeCommand(redisClient *c) {
|
253
|
+
if (c->argc == 1) {
|
254
|
+
pubsubUnsubscribeAllPatterns(c,1);
|
255
|
+
return;
|
256
|
+
} else {
|
257
|
+
int j;
|
258
|
+
|
259
|
+
for (j = 1; j < c->argc; j++)
|
260
|
+
pubsubUnsubscribePattern(c,c->argv[j],1);
|
261
|
+
}
|
262
|
+
}
|
263
|
+
|
264
|
+
void publishCommand(redisClient *c) {
|
265
|
+
int receivers = pubsubPublishMessage(c->argv[1],c->argv[2]);
|
266
|
+
addReplyLongLong(c,receivers);
|
267
|
+
}
|