1
0
mirror of https://github.com/fluencelabs/redis synced 2025-06-22 13:31:32 +00:00
Files
client-libraries
deps
design-documents
doc
AppendCommand.html
AppendOnlyFileHowto.html
AuthCommand.html
Benchmarks.html
BgrewriteaofCommand.html
BgsaveCommand.html
BlpopCommand.html
BrpoplpushCommand.html
CommandReference.html
Comparisons.html
ConfigCommand.html
Configuration.html
ConnectionHandlingSidebar.html
ControlCommandsSidebar.html
Credits.html
DbsizeCommand.html
DelCommand.html
DesignPatterns.html
EventLibray.html
ExistsCommand.html
ExpireCommand.html
FAQ.html
Features.html
FlushallCommand.html
FlushdbCommand.html
FromSqlToDataStructures.html
GenericCommandsSidebar.html
GetCommand.html
GetbitCommand.html
GetsetCommand.html
HackingStrings.html
HashCommandsSidebar.html
Hashes.html
HdelCommand.html
HexistsCommand.html
HgetCommand.html
HgetallCommand.html
HincrbyCommand.html
HlenCommand.html
HmgetCommand.html
HmsetCommand.html
HsetCommand.html
HsetnxCommand.html
IncrCommand.html
InfoCommand.html
IntroductionToRedisDataTypes.html
KeysCommand.html
LastsaveCommand.html
LindexCommand.html
ListCommandsSidebar.html
Lists.html
LlenCommand.html
LpopCommand.html
LrangeCommand.html
LremCommand.html
LsetCommand.html
LtrimCommand.html
MgetCommand.html
MonitorCommand.html
MoveCommand.html
MsetCommand.html
MultiExecCommand.html
NonexistentCommands.html
ObjectHashMappers.html
Pipelining.html
ProgrammingExamples.html
ProtocolSpecification.html
PublishSubscribe.html
QuickStart.html
QuitCommand.html
README.html
RandomkeyCommand.html
Redis0100ChangeLog.html
Redis0900ChangeLog.html
RedisBigData.html
RedisCLI.html
RedisEventLibrary.html
RedisGuides.html
RedisInternals.html
RedisPipelining.html
RedisStatus.html
Redis_1_2_0_Changelog.html
Redis_2_0_0_Changelog.html
Redis_2_0_Whats_new.html
RenameCommand.html
RenamenxCommand.html
ReplicationHowto.html
ReplyTypes.html
RoadMap.html
RpoplpushCommand.html
RpushCommand.html
SaddCommand.html
SaveCommand.html
ScardCommand.html
SdiffCommand.html
SdiffstoreCommand.html
SelectCommand.html
SetCommand.html
SetCommandsSidebar.html
SetbitCommand.html
SetexCommand.html
SetnxCommand.html
SetrangeCommand.html
Sets.html
ShutdownCommand.html
SideBar.html
SinterCommand.html
SinterstoreCommand.html
SismemberCommand.html
SlaveofCommand.html
SmembersCommand.html
SmoveCommand.html
SortCommand.html
SortedSetCommandsSidebar.html
SortedSets.html
Speed.html
SponsorshipHistory.html
SpopCommand.html
SrandmemberCommand.html
SremCommand.html
StringCommandsSidebar.html
Strings.html
StrlenCommand.html
SubstrCommand.html
SunionCommand.html
SunionstoreCommand.html
SupportedLanguages.html
SupportedPlatforms.html
TemplateCommand.html
TtlCommand.html
TwitterAlikeExample.html
TypeCommand.html
UnstableSource.html
VirtualMemorySpecification.html
VirtualMemoryUserGuide.html
ZaddCommand.html
ZcardCommand.html
ZincrbyCommand.html
ZrangeCommand.html
ZrangebyscoreCommand.html
ZrankCommand.html
ZremCommand.html
ZremrangebyrankCommand.html
ZremrangebyscoreCommand.html
ZscoreCommand.html
ZunionCommand.html
ZunionstoreCommand.html
index.html
redis.png
style.css
src
tests
utils
.gitignore
00-RELEASENOTES
BUGS
CLUSTER
CONTRIBUTING
COPYING
Changelog
INSTALL
Makefile
README
TODO
redis.conf
redis/doc/SortedSets.html

37 lines
4.0 KiB
HTML
Raw Normal View History

2009-12-23 11:15:07 -05:00
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<link type="text/css" rel="stylesheet" href="style.css" />
</head>
<body>
<div id="page">
<div id='header'>
<a href="index.html">
<img style="border:none" alt="Redis Documentation" src="redis.png">
</a>
</div>
<div id="pagecontent">
<div class="index">
<!-- This is a (PRE) block. Make sure it's left aligned or your toc title will be off. -->
<b>SortedSets: Contents</b><br>&nbsp;&nbsp;<a href="#Redis Sorted Set Type">Redis Sorted Set Type</a><br>&nbsp;&nbsp;<a href="#Implementation details">Implementation details</a>
</div>
<h1 class="wikiname">SortedSets</h1>
<div class="summary">
</div>
<div class="narrow">
&iuml;&raquo;&iquest;#sidebar <a href="SortedSetCommandsSidebar.html">SortedSetCommandsSidebar</a><h1><a name="Redis Sorted Set Type">Redis Sorted Set Type</a></h1>Redis Sorted Sets are, similarly to <a href="Sets.html">Sets</a>, collections of <a href="Strings.html">Redis Strings</a>. The difference is that every member of a Sorted Set hash an <b>associated score</b> that is used in order to take this member in order.<br/><br/>The <a href="ZaddCommand.html">ZADD</a> command is used to add a new member to a Sorted Set, specifying the score of the element. Calling ZADD against a member already present in the sorted set but using a different score will update the score for the element, moving it to the right position in order to preserve ordering.<br/><br/>It's possible to get ranges of elements from Sorted Sets in a very similar way to what happens with <a href="Lists.html">Lists</a> and the <a href="LrangeCommnad.html">LRANGE</a> command using the Sorted Sets <a href="ZrangeCommand.html">ZRANGE</a> command.<br/><br/>It's also possible to get or remove ranges of elements by score using the <a href="ZrangebyscoreCommand.html">ZRANGEBYSCORE</a> and <a href="ZremrangebyscoreCommand.html">ZREMRANGEBYSCORE</a> commands.<br/><br/>The max number of members in a sorted set is 232-1 (4294967295, more than 4 billion of members per set).<br/><br/>Note that while Sorted Sets are already ordered, it is still possible to use the <a href="SortCommand.html">SORT</a> command against sorted sets to get the elements in a different order.<h1><a name="Implementation details">Implementation details</a></h1>Redis Sets are implemented using a dual-ported data structure containing a skip list and an hash table. When an element is added a map between the element and the score is added to the hash table (so that given the element we get the score in O(1)), and a map between the score and the element is added in the skip list so that elements are taken in order.<br/><br/>Redis uses a special skip list implementation that is doubly linked so that it's possible to traverse the sorted set from tail to head if needed (Check the <a href="ZRevrangeCommand.html">ZREVRANGE</a> command).<br/><br/>When <a href="ZaddCommand.html">ZADD</a> is used in order to update the score of an element, Redis retrieve the score of the element using the hash table, so that it's fast to access the element inside the skip list (that's indexed by score) in order to update the position.<br/><br/>Like it happens for Sets the hash table resizing is a blocking operation performed synchronously so working with huge sorted sets (consisting of many millions of elements) care should be taken when mass-inserting a very big amount of elements in a Set while other clients are querying Redis at high speed.<br/><br/>It is possible that in the near future Redis will switch to skip lists even for the element =&gt; score map, so every Sorted Set will have two skip lists, one indexed by element and one indexed by score.
2009-12-23 11:15:07 -05:00
</div>
</div>
</div>
</body>
</html>