content
large_stringlengths
3
20.5k
url
large_stringlengths
53
192
branch
large_stringclasses
4 values
source
large_stringclasses
51 values
embeddings
listlengths
384
384
score
float64
-0.21
0.65
Redis keys are binary safe; this means that you can use any binary sequence as a key, from a string like "foo" to the content of a JPEG file. The empty string is also a valid key. A few other rules about keys: \* Very long keys are not a good idea. For instance a key of 1024 bytes is a bad idea not only memory-wise, bu...
https://github.com/redis/redis-doc/blob/master/docs/manual/keyspace.md
master
redis
[ -0.018877197057008743, 0.011534025892615318, -0.0976446121931076, -0.023981651291251183, -0.04508594051003456, -0.02412303164601326, 0.02262081950902939, 0.07005085051059723, 0.029532868415117264, -0.0038918163627386093, 0.03422446921467781, 0.049762383103370667, 0.09803662449121475, -0.07...
0.08756
key vanished between the two `GET` calls, since the second call was delayed more than 5 seconds. In the example above we used `EXPIRE` in order to set the expire (it can also be used in order to set a different expire to a key already having one, like `PERSIST` can be used in order to remove the expire and make the key...
https://github.com/redis/redis-doc/blob/master/docs/manual/keyspace.md
master
redis
[ -0.0454971045255661, -0.023592308163642883, -0.09627192467451096, 0.051568932831287384, -0.07137133181095123, -0.06426478922367096, 0.0102956248447299, 0.03663882613182068, 0.10274072736501694, -0.00936209224164486, 0.10211529582738876, 0.07116417586803436, 0.028952080756425858, -0.0660258...
0.067073
Keyspace notifications allow clients to subscribe to Pub/Sub channels in order to receive events affecting the Redis data set in some way. Examples of events that can be received are: \* All the commands affecting a given key. \* All the keys receiving an LPUSH operation. \* All the keys expiring in the database 0. Not...
https://github.com/redis/redis-doc/blob/master/docs/manual/keyspace-notifications.md
master
redis
[ 0.0027985749766230583, -0.13115327060222626, -0.01337351743131876, 0.05162728205323219, -0.002924520056694746, -0.046527981758117676, 0.09828939288854599, -0.03874298185110092, 0.12168128043413162, 0.02949879877269268, -0.002661541337147355, 0.03313561901450157, 0.07017296552658081, -0.047...
0.140879
a `move\_from` event for the source key, and a `move\_to` event for the destination key. \* `COPY` generates a `copy\_to` event. \* `MIGRATE` generates a `del` event if the source key is removed. \* `RESTORE` generates a `restore` event for the key. \* `EXPIRE` and all its variants (`PEXPIRE`, `EXPIREAT`, `PEXPIREAT`) ...
https://github.com/redis/redis-doc/blob/master/docs/manual/keyspace-notifications.md
master
redis
[ -0.09879569709300995, -0.027825525030493736, 0.0231893640011549, 0.020846931263804436, 0.04340411722660065, -0.021019773557782173, 0.06684146821498871, -0.030583888292312622, 0.14529019594192505, 0.049746062606573105, 0.10513228178024292, 0.0537763386964798, 0.023150429129600525, -0.084171...
0.153596
generates an `spop` event, and an additional `del` event if the resulting set is empty and the key is removed. \* `SINTERSTORE`, `SUNIONSTORE`, `SDIFFSTORE` generate `sinterstore`, `sunionstore`, `sdiffstore` events respectively. In the special case the resulting set is empty, and the key where the result is stored alr...
https://github.com/redis/redis-doc/blob/master/docs/manual/keyspace-notifications.md
master
redis
[ -0.11810934543609619, 0.0462949313223362, -0.021711263805627823, 0.037964653223752975, 0.011804853565990925, -0.06801383942365646, 0.09404902905225754, -0.04242172837257385, 0.11865299940109253, 0.018660228699445724, 0.08750161528587341, -0.023132480680942535, 0.1296718418598175, -0.087952...
0.09521
as a result there are no guarantees that the Redis server will be able to generate the `expired` event at the time the key time to live reaches the value of zero. If no command targets the key constantly, and there are many keys with a TTL associated, there can be a significant delay between the time the key time to li...
https://github.com/redis/redis-doc/blob/master/docs/manual/keyspace-notifications.md
master
redis
[ -0.018346602097153664, -0.052643440663814545, -0.0325712226331234, 0.06451500952243805, 0.02453233115375042, -0.02735207974910736, -0.004226659424602985, -0.05004630237817764, 0.13686524331569672, 0.020388849079608917, 0.03634161874651909, 0.03288259729743004, 0.057377301156520844, -0.0503...
0.079039
Client-side caching is a technique used to create high performance services. It exploits the memory available on application servers, servers that are usually distinct computers compared to the database nodes, to store some subset of the database information directly in the application side. Normally when data is requi...
https://github.com/redis/redis-doc/blob/master/docs/manual/client-side-caching.md
master
redis
[ -0.047868046909570694, 0.05521098151803017, -0.04469013214111328, 0.029680512845516205, -0.08132872730493546, -0.049901362508535385, 0.11655084043741226, -0.012562969699501991, 0.0816565603017807, 0.029918823391199112, -0.04149544984102249, 0.07394067198038101, 0.11220436543226242, -0.0850...
0.106611
this command. Regardless of what schema is used, there is a simple fact: many very large applications implement some form of client-side caching, because it is the next logical step to having a fast store or a fast cache server. For this reason Redis 6 implements direct support for client-side caching, in order to make...
https://github.com/redis/redis-doc/blob/master/docs/manual/client-side-caching.md
master
redis
[ 0.003669165773317218, -0.027157695963978767, -0.0791684165596962, 0.03988855332136154, 0.02911704033613205, -0.07477013766765594, 0.07186684012413025, -0.021527601405978203, 0.09780373424291611, 0.03389369323849678, -0.010036819614470005, 0.0660640075802803, 0.025481747463345528, -0.068277...
0.201857
clients' structures, that would force a garbage collection procedure when the client disconnects: instead what we do is just store client IDs (each Redis client has a unique numerical ID). If a client disconnects, the information will be incrementally garbage collected as caching slots are invalidated. \* There is a si...
https://github.com/redis/redis-doc/blob/master/docs/manual/client-side-caching.md
master
redis
[ -0.028499918058514595, -0.015400857664644718, -0.05364847183227539, 0.043737344443798065, -0.0510549321770668, -0.08620608597993851, 0.08317871391773224, -0.02678314596414566, 0.09961502999067307, 0.004830510355532169, -0.04252784699201584, 0.10560014843940735, 0.06972108036279678, -0.0531...
0.139374
in order to read the invalidation messages, is that using Pub/Sub is entirely a trick \*\*in order to reuse old client implementations\*\*, but actually the message is not really sent to a channel and received by all the clients subscribed to it. Only the connection we specified in the `REDIRECT` argument of the `CLIEN...
https://github.com/redis/redis-doc/blob/master/docs/manual/client-side-caching.md
master
redis
[ -0.059982798993587494, -0.034637950360774994, 0.04169498011469841, 0.013552723452448845, -0.006543702911585569, -0.0756724551320076, 0.034918371587991714, -0.0193912573158741, 0.05466550961136818, 0.031216779723763466, -0.12398150563240051, 0.04061698168516159, 0.054081179201602936, 0.0343...
0.103135
mode we have the following main behaviors: \* Clients enable client-side caching using the `BCAST` option, specifying one or more prefixes using the `PREFIX` option. For instance: `CLIENT TRACKING on REDIRECT 10 BCAST PREFIX object: PREFIX user:`. If no prefix is specified at all, the prefix is assumed to be the empty ...
https://github.com/redis/redis-doc/blob/master/docs/manual/client-side-caching.md
master
redis
[ -0.07423403859138489, -0.038022566586732864, 0.03805386647582054, 0.02773449197411537, -0.10210365802049637, -0.08177162706851959, 0.055836938321590424, -0.04143188148736954, 0.02317984588444233, 0.0009916272247210145, -0.043166860938072205, -0.01168475579470396, 0.11485949158668518, -0.02...
0.06461
[D] server -> client: "bar" (the reply of "GET foo") Client cache: don't set "bar" since the entry for "foo" is missing. Such a race condition is not possible when using a single connection for both data and invalidation messages, since the order of the messages is always known in that case. ## What to do when losing c...
https://github.com/redis/redis-doc/blob/master/docs/manual/client-side-caching.md
master
redis
[ -0.04253872483968735, -0.028160786256194115, 0.041601382195949554, 0.022482343018054962, -0.08854664117097855, -0.0813128724694252, 0.0037380352150648832, -0.03175821155309677, 0.06958159804344177, 0.059995800256729126, -0.07508554309606552, 0.05266870558261871, 0.0214021448045969, -0.0170...
0.024463
This article describes the design and implementation of a [very simple Twitter clone](https://github.com/antirez/retwis) written using PHP with Redis as the only database. The programming community has traditionally considered key-value stores as a special purpose database that couldn't be used as a drop-in replacement...
https://github.com/redis/redis-doc/blob/master/docs/manual/patterns/twitter-clone.md
master
redis
[ -0.0555696114897728, -0.019066136330366135, -0.08496847003698349, 0.005305607803165913, -0.05503286421298981, -0.07438364624977112, 0.011532294563949108, 0.06898646056652069, -0.0024558722507208586, 0.0019666673615574837, 0.00455093290656805, 0.05931594967842102, 0.126090869307518, -0.0587...
0.158328
this way will work as long as there is only one client working with the key \_foo\_ at one time. See what happens if two clients are accessing this key at the same time: x = GET foo (yields 10) y = GET foo (yields 10) x = x + 1 (x is now 11) y = y + 1 (y is now 11) SET foo x (foo is now 11) SET foo y (foo is now 11) So...
https://github.com/redis/redis-doc/blob/master/docs/manual/patterns/twitter-clone.md
master
redis
[ -0.10032594203948975, 0.013617551885545254, -0.08839064091444016, -0.012545770034193993, -0.11764363199472427, -0.046474844217300415, 0.08438004553318024, 0.03162091597914696, 0.08128754049539566, -0.003471390577033162, 0.03748283162713051, 0.057927828282117844, 0.08507604897022247, -0.066...
0.163511
it is better to start introducing Sets first (which are a very useful data structure per se), and later Sorted Sets. There are more data types than just Lists. Redis also supports Sets, which are unsorted collections of elements. It is possible to add, remove, and test for existence of members, and perform the intersec...
https://github.com/redis/redis-doc/blob/master/docs/manual/patterns/twitter-clone.md
master
redis
[ 0.017889244481921196, -0.02065686136484146, -0.02779267355799675, 0.028402352705597878, -0.0481533445417881, -0.0584004670381546, 0.06558547914028168, -0.019709883257746696, -0.01932639814913273, 0.00683178985491395, 0.005439606960862875, -0.007715287618339062, 0.07309726625680923, -0.0721...
0.0902
set fields in the hash, that can be retrieved with `HGET` later. It is possible to check if a field exists with `HEXISTS`, or to increment a hash field with `HINCRBY` and so forth. Hashes are the ideal data structure to represent \*objects\*. For example we use Hashes in order to represent Users and Updates in our Twit...
https://github.com/redis/redis-doc/blob/master/docs/manual/patterns/twitter-clone.md
master
redis
[ -0.0395529568195343, 0.06976018846035004, -0.11446551978588104, -0.04023008793592453, -0.015681415796279907, -0.06981757283210754, 0.04659217968583107, 0.010425472632050514, 0.011668787337839603, 0.012111419811844826, 0.013505810871720314, 0.043380629271268845, 0.07320237904787064, -0.1118...
0.04601
need in our system. A user might have users who follow them, which we'll call their followers. A user might follow other users, which we'll call a following. We have a perfect data structure for this. That is... Sets. The uniqueness of Sets elements, and the fact we can test in constant time for existence, are two inte...
https://github.com/redis/redis-doc/blob/master/docs/manual/patterns/twitter-clone.md
master
redis
[ -0.06699760258197784, -0.023328997194767, -0.05484004691243172, -0.015151108615100384, -0.052950743585824966, 0.024698980152606964, 0.04668732360005379, 0.008610527031123638, 0.03028954565525055, 0.005224752239882946, 0.03226067125797272, 0.038128484040498734, 0.10878314077854156, -0.03978...
0.066645
message. \* Ok authenticated! Set "fea5e81ac8ca77622bed1c2132a021f9" (the value of user:1000 `auth` field) as the "auth" cookie. This is the actual code: include("retwis.php"); # Form sanity checks if (!gt("username") || !gt("password")) goback("You need to enter both username and password to login."); # The form is ok...
https://github.com/redis/redis-doc/blob/master/docs/manual/patterns/twitter-clone.md
master
redis
[ -0.017948804423213005, -0.016113517805933952, -0.12957972288131714, -0.009731396101415157, -0.028691302984952927, 0.012381336651742458, 0.053635209798812866, 0.010996658354997635, -0.013726188801229, -0.04798797145485878, 0.019163914024829865, -0.01985786110162735, 0.060517072677612305, -0...
0.032034
body of the post, which is, the actual status message. After we create a post and we obtain the post ID, we need to LPUSH the ID in the timeline of every user that is following the author of the post, and of course in the list of posts of the author itself (everybody is virtually following herself/himself). This is the...
https://github.com/redis/redis-doc/blob/master/docs/manual/patterns/twitter-clone.md
master
redis
[ 0.03431500867009163, 0.0433548241853714, -0.06285464018583298, -0.012631463818252087, 0.020177947357296944, 0.010868651792407036, 0.02827823907136917, -0.008562348783016205, 0.03935038298368454, -0.04838785156607628, 0.04498540982604027, 0.0009650788269937038, 0.01986371912062168, -0.05070...
0.08484
follower relationship. We just need to `ZADD` calls: ZADD following:1000 5000 ZADD followers:5000 1000 Note the same pattern again and again. In theory with a relational database, the list of following and followers would be contained in a single table with fields like `following\_id` and `follower\_id`. You can extrac...
https://github.com/redis/redis-doc/blob/master/docs/manual/patterns/twitter-clone.md
master
redis
[ -0.04905617982149124, 0.0068979691714048386, -0.11288576573133469, -0.004793154075741768, -0.06280730664730072, -0.01938312128186226, 0.03693185746669769, -0.008580916561186314, 0.0486694872379303, -0.0033818967640399933, 0.07531506568193436, 0.011993504129350185, 0.16452044248580933, -0.0...
0.041875
Distributed locks are a very useful primitive in many environments where different processes must operate with shared resources in a mutually exclusive way. There are a number of libraries and blog posts describing how to implement a DLM (Distributed Lock Manager) with Redis, but every library uses a different approach...
https://github.com/redis/redis-doc/blob/master/docs/manual/patterns/distributed-locks.md
master
redis
[ -0.11510798335075378, -0.0425490103662014, -0.051987189799547195, -0.017813825979828835, -0.030461197718977928, -0.018708519637584686, 0.021336575970053673, -0.04522878676652908, 0.0050275069661438465, 0.04281244054436684, -0.030235478654503822, 0.05490907281637192, 0.016352597624063492, -...
0.135721
gets promoted to master. 4. Client B acquires the lock to the same resource A already holds a lock for. \*\*SAFETY VIOLATION!\*\* Sometimes it is perfectly fine that, under special circumstances, for example during a failure, multiple clients can hold the lock at the same time. If this is the case, you can use your rep...
https://github.com/redis/redis-doc/blob/master/docs/manual/patterns/distributed-locks.md
master
redis
[ -0.10037028789520264, -0.02299121581017971, 0.0024010108318179846, -0.029088113456964493, -0.046302493661642075, 0.009340477176010609, 0.07739688456058502, -0.08304538577795029, 0.03374472260475159, 0.04166031256318092, -0.011643685400485992, 0.009440090507268906, 0.14035440981388092, -0.0...
-0.006466
system where we don’t have such guarantees. ## The Redlock Algorithm In the distributed version of the algorithm we assume we have N Redis masters. Those nodes are totally independent, so we don’t use replication or any other implicit coordination system. We already described how to acquire and release the lock safely ...
https://github.com/redis/redis-doc/blob/master/docs/manual/patterns/distributed-locks.md
master
redis
[ -0.07638978958129883, -0.031581249088048935, -0.040612660348415375, 0.010587528347969055, 0.010946745984256268, -0.019622405990958214, -0.004213398322463036, -0.04837781563401222, 0.07328908890485764, 0.029176460579037666, 0.00020298892923165113, 0.06379932165145874, 0.05078870803117752, -...
0.092033
the lock, it should try again after a random delay in order to try to desynchronize multiple clients trying to acquire the lock for the same resource at the same time (this may result in a split brain condition where nobody wins). Also the faster a client tries to acquire the lock in the majority of Redis instances, th...
https://github.com/redis/redis-doc/blob/master/docs/manual/patterns/distributed-locks.md
master
redis
[ -0.07912877202033997, -0.05116700381040573, -0.03296662122011185, 0.00480100279673934, -0.001445857109501958, -0.00321242050267756, 0.02971663698554039, -0.06359472870826721, 0.07193857431411743, 0.012705921195447445, 0.010721534490585327, 0.07788490504026413, 0.02492433786392212, -0.07660...
0.076826
The system liveness is based on three main features: 1. The auto release of the lock (since keys expire): eventually keys are available again to be locked. 2. The fact that clients, usually, will cooperate removing the locks when the lock was not acquired, or when the lock was acquired and the work terminated, making i...
https://github.com/redis/redis-doc/blob/master/docs/manual/patterns/distributed-locks.md
master
redis
[ -0.07478491961956024, -0.047656890004873276, -0.03080660291016102, 0.03410176932811737, 0.03288016840815544, -0.008025300689041615, 0.01333854254335165, -0.012936951592564583, 0.13615064322948456, 0.05151456221938133, 0.00467844819650054, 0.14242896437644958, -0.0001145021669799462, -0.033...
0.05935
guarantee this we just need to make an instance, after a crash, unavailable for at least a bit more than the max `TTL` we use. This is the time needed for all the keys about the locks that existed when the instance crashed to become invalid and be automatically released. Using \*delayed restarts\* it is basically possi...
https://github.com/redis/redis-doc/blob/master/docs/manual/patterns/distributed-locks.md
master
redis
[ -0.11344043910503387, -0.036546479910612106, -0.01275124866515398, -0.019190654158592224, -0.03352813050150871, -0.00029464310500770807, 0.024941924959421158, 0.020043697208166122, 0.07055330276489258, 0.04298032820224762, 0.0012131386902183294, 0.0932602658867836, 0.019629158079624176, -0...
0.06963
Bulk loading is the process of loading Redis with a large amount of pre-existing data. Ideally, you want to perform this operation quickly and efficiently. This document describes some strategies for bulk loading data in Redis. ## Bulk loading using the Redis protocol Using a normal Redis client to perform bulk loading...
https://github.com/redis/redis-doc/blob/master/docs/manual/patterns/bulk-loading.md
master
redis
[ -0.04932612180709839, -0.048947472125291824, -0.07242812216281891, 0.03026680462062359, -0.057889778167009354, -0.11608707904815674, 0.0216267891228199, 0.03426147252321243, 0.01954844780266285, 0.029690302908420563, -0.0015193037688732147, 0.0401608981192112, 0.03418397530913353, -0.06821...
0.107901
above function it is possible to easily generate the key value pairs in the above example, with this program: (0...1000).each{|n| STDOUT.write(gen\_redis\_proto("SET","Key#{n}","Value#{n}")) } We can run the program directly in pipe to redis-cli in order to perform our first mass import session. $ ruby proto.rb | redis...
https://github.com/redis/redis-doc/blob/master/docs/manual/patterns/bulk-loading.md
master
redis
[ -0.01923207938671112, -0.001446290174499154, -0.10135883092880249, 0.0262131504714489, -0.08496928960084915, -0.06584162265062332, 0.03683710843324661, 0.03487924486398697, 0.0011955380905419588, -0.027272086590528488, -0.045561932027339935, -0.01811632700264454, 0.03406831622123718, -0.07...
0.055794
Redis is not exactly a key-value store, since values can be complex data structures. However it has an external key-value shell: at API level data is addressed by the key name. It is fair to say that, natively, Redis only offers \*primary key access\*. However since Redis is a data structures server, its capabilities c...
https://github.com/redis/redis-doc/blob/master/docs/manual/patterns/indexes/index.md
master
redis
[ -0.012840455397963524, -0.01126725971698761, -0.09591677784919739, 0.021400408819317818, -0.06745761632919312, -0.057213302701711655, 0.01820492185652256, 0.025038449093699455, 0.03689604252576828, 0.02900463156402111, -0.029998643323779106, 0.054800476878881454, 0.07396382838487625, -0.04...
0.151755
to index some field of an object which is stored elsewhere. Instead of using the sorted set value directly to store the data associated with the indexed field, it is possible to store just the ID of the object. For example I may have Redis hashes representing users. Each user is represented by a single key, directly ac...
https://github.com/redis/redis-doc/blob/master/docs/manual/patterns/indexes/index.md
master
redis
[ 0.013118124566972256, 0.15321098268032074, -0.07655221968889236, 0.05595779046416283, -0.04733375087380409, 0.058507148176431656, 0.09746932983398438, 0.04754774644970894, 0.0005735865561291575, -0.04141777381300926, -0.04110328108072281, 0.03854891285300255, 0.06449539959430695, -0.053337...
0.064298
values with different errors, because they use an exponential representation internally. However what is interesting for indexing purposes is that the score is always able to represent without any error numbers between -9007199254740992 and 9007199254740992, which is `-/+ 2^53`. When representing much larger numbers, y...
https://github.com/redis/redis-doc/blob/master/docs/manual/patterns/indexes/index.md
master
redis
[ -0.016766391694545746, -0.00040463233017362654, -0.046126000583171844, 0.010722676292061806, -0.016624080017209053, -0.04585679993033409, 0.013512423262000084, 0.10907354950904846, 0.0962911993265152, 0.009187531657516956, -0.03145677223801613, -0.004435303620994091, 0.10132908076047897, 0...
0.149419
search query ever encountered. Then when we want to complete the user input, we execute a range query using `ZRANGE` with the `BYLEX` argument. Imagine the user is typing "bit" inside the search form, and we want to offer possible search keywords starting for "bit". We send Redis a command like that: ZRANGE myindex "[b...
https://github.com/redis/redis-doc/blob/master/docs/manual/patterns/indexes/index.md
master
redis
[ -0.01736619509756565, 0.03899373114109039, -0.04680941253900528, 0.05371607467532158, -0.051817115396261215, 0.003525722539052367, 0.1262882947921753, 0.054092034697532654, -0.005970947444438934, -0.04085897281765938, -0.010120425373315811, -0.003968772944062948, 0.15062224864959717, -0.03...
0.09783
will adapt automatically. A refinement to this algorithm is to pick entries in the list according to their weight: the higher the score, the less likely entries are picked in order to decrement its score, or evict them. Normalizing strings for case and accents --- In the completion examples we always used lowercase str...
https://github.com/redis/redis-doc/blob/master/docs/manual/patterns/indexes/index.md
master
redis
[ 0.013015388511121273, 0.0389411561191082, -0.010792376473546028, 0.024715343490242958, -0.04437224566936493, 0.08633234351873398, 0.09136147052049637, -0.0052887494675815105, -0.0006635497556999326, -0.049681950360536575, 0.0012948074145242572, -0.007584706414490938, 0.12666425108909607, 0...
0.146939
00324823481:foo ZADD myindex 0 12838349234:bar ZADD myindex 0 00000000111:zap ZRANGE myindex 0 -1 1) "00000000111:zap" 2) "00324823481:foo" 3) "12838349234:bar" We effectively created an index using a numerical field which can be as big as we want. This also works with floating point numbers of any precision by making ...
https://github.com/redis/redis-doc/blob/master/docs/manual/patterns/indexes/index.md
master
redis
[ 0.028596043586730957, 0.03672002628445625, -0.04741329699754715, -0.029667332768440247, -0.06228674203157425, -0.06007646769285202, 0.04222441092133522, 0.031166596338152885, 0.006825629621744156, 0.0186129342764616, -0.08468236029148102, 0.014186032116413116, 0.060912538319826126, 0.01735...
0.05717
the operations of updating the index. In order to remove the old information we indexed for the object ID 90, regardless of the \*current\* fields values of the object, we just have to retrieve the hash value by object ID and `ZREM` it in the sorted set view. Representing and querying graphs using a hexastore === One c...
https://github.com/redis/redis-doc/blob/master/docs/manual/patterns/indexes/index.md
master
redis
[ 0.016758359968662262, 0.0922454223036766, -0.04268019273877144, 0.0448121540248394, -0.05450836941599846, 0.045609284192323685, 0.04080212861299515, -0.026369454339146614, 0.007844515144824982, 0.015064639039337635, -0.021553609520196915, 0.06773494929075241, 0.04482842609286308, -0.008231...
0.125396
our coordinates. The max value of both variables is 400. In the next figure, the blue box represents our query. We want all the points where `x` is between 50 and 100, and where `y` is between 100 and 300. ![Points in the space](2idx\_0.png) In order to represent data that makes these kinds of queries fast to perform, ...
https://github.com/redis/redis-doc/blob/master/docs/manual/patterns/indexes/index.md
master
redis
[ -0.0011762555222958326, 0.033692821860313416, -0.053942255675792694, -0.026823069900274277, 0.012545710429549217, 0.04875468462705612, 0.0665181502699852, 0.014119628816843033, 0.03331046178936958, -0.06199219450354576, -0.05371839180588722, 0.06317193061113358, 0.07077831029891968, 0.0329...
0.138427
between 200 and 203 (range=4) 6 bits: x between 72 and 79, y between 200 and 207 (range=8) 8 bits: x between 64 and 79, y between 192 and 207 (range=16) And so forth. Now we have definitely better granularity! As you can see substituting N bits from the index gives us search boxes of side `2^(N/2)`. So what we do is ch...
https://github.com/redis/redis-doc/blob/master/docs/manual/patterns/indexes/index.md
master
redis
[ 0.0509396456182003, 0.08200890570878983, -0.04270308464765549, 0.01647944003343582, 0.03373570367693901, -0.0014123129658401012, -0.02833545207977295, 0.003322828793898225, -0.05658042058348656, -0.03197808563709259, -0.11390721797943115, 0.002499478170648217, 0.021411867812275887, -0.0171...
0.022814
numbers, the simplest approach is probably to convert them to integers by multiplying the integer for a power of ten proportional to the number of digits after the dot you want to retain. Non range indexes === So far we checked indexes which are useful to query by range or by single item. However other Redis data struc...
https://github.com/redis/redis-doc/blob/master/docs/manual/patterns/indexes/index.md
master
redis
[ -0.025239815935492516, 0.0013879073085263371, -0.08964131027460098, 0.05395742878317833, -0.007624091114848852, -0.030736777931451797, 0.08197031915187836, -0.015756458044052124, 0.024113383144140244, 0.011573807336390018, -0.02993340790271759, 0.028635306283831596, 0.09669344872236252, -0...
0.162978
Redis pipelining is a technique for improving performance by issuing multiple commands at once without waiting for the response to each individual command. Pipelining is supported by most Redis clients. This document describes the problem that pipelining is designed to solve and how pipelining works in Redis. ## Reques...
https://github.com/redis/redis-doc/blob/master/docs/manual/pipelining/index.md
master
redis
[ -0.05832045152783394, -0.0009275501361116767, -0.04042929410934448, 0.03068295493721962, -0.06595876812934875, -0.12039823830127716, -0.004860587418079376, 0.03472502902150154, 0.05959531292319298, -0.0074737402610480785, -0.0458562858402729, 0.03433895483613014, -0.0053888168185949326, -0...
0.156567
\*Server:\* 3 \* \*Server:\* 4 > \*\*IMPORTANT NOTE\*\*: While the client sends commands using pipelining, the server will be forced to queue the replies, using memory. So if you need to send a lot of commands with pipelining, it is better to send them as batches each containing a reasonable number, for instance 10k co...
https://github.com/redis/redis-doc/blob/master/docs/manual/pipelining/index.md
master
redis
[ -0.010625154711306095, -0.000710973225068301, -0.03692837432026863, 0.019654035568237305, -0.07595121115446091, -0.10240593552589417, -0.002374911680817604, 0.07666590809822083, 0.04907682165503502, 0.03090502694249153, -0.03321879729628563, 0.023166848346590996, -0.04961515963077545, -0.0...
0.084665
page, you may still wonder why a Redis benchmark like the following (in pseudo code), is slow even when executed in the loopback interface, when the server and the client are running in the same physical machine: ```sh FOR-ONE-SECOND: Redis.SET("foo","bar") END ``` After all, if both the Redis process and the benchmark...
https://github.com/redis/redis-doc/blob/master/docs/manual/pipelining/index.md
master
redis
[ 0.0188165083527565, -0.05812472477555275, -0.09026898443698883, 0.08015568554401398, 0.0017186893383041024, -0.0880977064371109, -0.0089646577835083, 0.013046792708337307, 0.10452958196401596, -0.052096519619226456, -0.02528504654765129, 0.10483162850141525, 0.009147548116743565, -0.103156...
0.1205
In interactive mode, `redis-cli` has basic line editing capabilities to provide a familiar typing experience. To launch the program in special modes, you can use several options, including: \* Simulate a replica and print the replication stream it receives from the primary. \* Check the latency of a Redis server and di...
https://github.com/redis/redis-doc/blob/master/docs/connect/cli.md
master
redis
[ -0.024115504696965218, -0.06179775670170784, -0.12388251721858978, 0.00950063206255436, -0.05195223540067673, -0.09378980100154877, 0.04866645485162735, 0.013773123733699322, 0.07118682563304901, -0.002389056608080864, -0.012297622859477997, -0.05526680126786232, 0.07257328927516937, -0.04...
0.171698
perform authentication saving the need of explicitly using the `AUTH` command: $ redis-cli -a myUnguessablePazzzzzword123 PING PONG \*\*NOTE:\*\* For security reasons, provide the password to `redis-cli` automatically via the `REDISCLI\_AUTH` environment variable. Finally, it's possible to send a command that operates ...
https://github.com/redis/redis-doc/blob/master/docs/connect/cli.md
master
redis
[ -0.007267476990818977, 0.0027002652641385794, -0.13363786041736603, -0.031771767884492874, -0.10528013855218887, -0.03451269119977951, 0.09628123790025711, -0.020731842145323753, 0.015529579482972622, 0.037217773497104645, -0.02494877204298973, -0.040751468390226364, 0.10092633217573166, -...
0.050813
set to 0, so commands are just executed ASAP: $ redis-cli -r 5 INCR counter\_value (integer) 1 (integer) 2 (integer) 3 (integer) 4 (integer) 5 To run the same command indefinitely, use `-1` as the count value. To monitor over time the RSS memory size it's possible to use the following command: $ redis-cli -r -1 -i 1 IN...
https://github.com/redis/redis-doc/blob/master/docs/connect/cli.md
master
redis
[ 0.01636514626443386, -0.012263800017535686, -0.1644161492586136, 0.061133310198783875, -0.014929188415408134, -0.08635424077510834, 0.05513395369052887, 0.01829732209444046, 0.05972565338015556, 0.03094078227877617, 0.014514687471091747, -0.023218456655740738, 0.07641654461622238, -0.04873...
0.158825
can see the prompt changes accordingly when connecting to a different server instance. If a connection is attempted to an instance that is unreachable, the `redis-cli` goes into disconnected mode and attempts to reconnect with each new command: 127.0.0.1:6379> CONNECT 127.0.0.1 9999 Could not connect to Redis at 127.0....
https://github.com/redis/redis-doc/blob/master/docs/connect/cli.md
master
redis
[ 0.035929471254348755, -0.05561660975217819, -0.06263028830289841, -0.01866624318063259, 0.0009865963365882635, -0.09070822596549988, 0.029808448627591133, -0.04556695744395256, 0.11262765526771545, -0.04484634846448898, 0.018782449886202812, -0.0011366193648427725, 0.03575751185417175, 0.0...
0.06259
`@set` - `@sorted\_set` - `@hash` - `@pubsub` - `@transactions` - `@connection` - `@server` - `@scripting` - `@hyperloglog` - `@cluster` - `@geo` - `@stream` \* `HELP ` shows specific help for the command given as argument. For example in order to show help for the `PFADD` command, use: 127.0.0.1:6379> HELP PFADD PFADD...
https://github.com/redis/redis-doc/blob/master/docs/connect/cli.md
master
redis
[ 0.03503258153796196, -0.011440571397542953, -0.0419955737888813, 0.012923786416649818, 0.011394945904612541, -0.010083578526973724, 0.09181126207113266, 0.03720478340983391, -0.036929354071617126, 0.023082224652171135, 0.036380402743816376, 0.003752906108275056, 0.004485776647925377, 0.060...
0.122828
Biggest hash found so far 'myobject' with 3 fields -------- summary ------- Sampled 506 keys in the keyspace! Total key length in bytes is 3452 (avg len 6.82) Biggest string found 'counter:\_\_rand\_int\_\_' has 6 bytes Biggest list found 'mylist' has 100004 items Biggest hash found 'myobject' has 3 fields 504 strings ...
https://github.com/redis/redis-doc/blob/master/docs/connect/cli.md
master
redis
[ 0.003376021748408675, 0.01147250086069107, -0.07398974895477295, 0.003121649846434593, -0.00035874522291123867, -0.09698117524385452, 0.07715746760368347, 0.08597592264413834, -0.0009476703125983477, 0.04711684212088585, -0.026199979707598686, 0.04199705272912979, 0.0697329044342041, -0.07...
0.097333
'\*' Reading messages... (press Ctrl-C to quit) 1) "PSUBSCRIBE" 2) "\*" 3) (integer) 1 The \*reading messages\* message shows that we entered Pub/Sub mode. When another client publishes some message in some channel, such as with the command `redis-cli PUBLISH mychannel mymessage`, the CLI in Pub/Sub mode will show some...
https://github.com/redis/redis-doc/blob/master/docs/connect/cli.md
master
redis
[ 0.06511305272579193, -0.0414755754172802, -0.09170754253864288, 0.012480080127716064, 0.02923785336315632, -0.05207016319036484, 0.07448742538690567, -0.008206676691770554, 0.04352134093642235, 0.01935034617781639, -0.057410262525081635, -0.02805672585964203, 0.05038690194487572, 0.0209844...
0.101666
\*intrinsic latency\* because it's mostly opaque to the programmer. If the Redis instance has high latency regardless of all the obvious things that may be the source cause, it's worth to check what's the best your system can do by running `redis-cli` in this special mode directly in the system you are running Redis se...
https://github.com/redis/redis-doc/blob/master/docs/connect/cli.md
master
redis
[ 0.015250985510647297, -0.08446367084980011, -0.06026751548051834, 0.025875648483633995, 0.03934406489133835, -0.13407431542873383, -0.0015234784223139286, -0.001554898452013731, 0.076375313103199, -0.019033243879675865, -0.0030843080021440983, -0.07183557003736496, -0.03500478342175484, -0...
0.070657
Performing an LRU simulation Redis is often used as a cache with [LRU eviction](/topics/lru-cache). Depending on the number of keys and the amount of memory allocated for the cache (specified via the `maxmemory` directive), the amount of cache hits and misses will change. Sometimes, simulating the rate of hits is very ...
https://github.com/redis/redis-doc/blob/master/docs/connect/cli.md
master
redis
[ -0.028993375599384308, -0.06177422031760216, -0.07696127891540527, 0.009591152891516685, -0.013626485131680965, -0.14667513966560364, -0.03184134513139725, 0.04218440502882004, 0.07055298238992691, -0.005011092871427536, -0.002237520180642605, 0.05289649963378906, 0.033145733177661896, -0....
0.146251
Hits: 135457 (96.58%) | Misses: 4793 (3.42%) 140500 Gets/sec | Hits: 135947 (96.76%) | Misses: 4553 (3.24%) With 500MB there is sufficient space for the key quantity (10 million) and distribution (80-20 style).
https://github.com/redis/redis-doc/blob/master/docs/connect/cli.md
master
redis
[ 0.06475815922021866, -0.0777570828795433, -0.07883458584547043, -0.0005392248276621103, -0.0437522828578949, -0.029792672023177147, 0.013232167810201645, 0.06290051341056824, 0.025178974494338036, 0.04281509667634964, 0.025733571499586105, -0.032569851726293564, 0.07593466341495514, -0.100...
0.02695
You can connect to Redis in the following ways: \* With the `redis-cli` command line tool \* Use RedisInsight as a graphical user interface \* Via a client library for your programming language ## Redis command line interface The [Redis command line interface](/docs/connect/cli) (also known as `redis-cli`) is a termina...
https://github.com/redis/redis-doc/blob/master/docs/connect/_index.md
master
redis
[ -0.04063607007265091, -0.10375478863716125, -0.14102302491664886, 0.020880842581391335, -0.04281872883439064, -0.07039293646812439, 0.04519201070070267, 0.05574453994631767, -0.0003646320546977222, -0.03366972878575325, -0.0329744778573513, 0.005924306344240904, 0.04703962802886963, -0.011...
0.154905
Install Redis and the Redis client, then connect your Go application to a Redis database. ## go-redis [go-redis](https://github.com/redis/go-redis) provides Go clients for various flavors of Redis and a type-safe API for each Redis command. ### Install `go-redis` supports last two Go versions and only works with Go mod...
https://github.com/redis/redis-doc/blob/master/docs/connect/clients/go.md
master
redis
[ -0.024085640907287598, -0.09080158919095993, -0.13225507736206055, -0.03228927403688431, -0.05625308305025101, -0.0552549734711647, 0.017847726121544838, 0.08356788009405136, -0.03284626454114914, -0.017538510262966156, -0.013603528030216694, 0.025138286873698235, 0.060014523565769196, 0.0...
0.035213
Install Redis and the Redis client, then connect your Python application to a Redis database. ## redis-py Get started with the [redis-py](https://github.com/redis/redis-py) client for Redis. `redis-py` requires a running Redis or [Redis Stack](/docs/getting-started/install-stack/) server. See [Getting started](/docs/ge...
https://github.com/redis/redis-doc/blob/master/docs/connect/clients/python.md
master
redis
[ -0.05085067078471184, -0.06019609794020653, -0.06949558854103088, 0.02259618043899536, -0.0497237928211689, -0.127751886844635, -0.02678769640624523, 0.0367145910859108, -0.006109344307333231, -0.008476132526993752, -0.048298146575689316, 0.053358208388090134, 0.03102903813123703, -0.00317...
0.038465
= rs.search( Query("Paul @age:[30 40]") ) # Result{1 total, docs: [Document {'id': 'user:3', 'payload': None, 'json': '{"name":"Paul Zamir","email":"paul.zamir@example.com","age":35,"city":"Tel Aviv"}'}]} ``` Query using JSON Path expressions. ```python rs.search( Query("Paul").return\_field("$.city", as\_field="city")...
https://github.com/redis/redis-doc/blob/master/docs/connect/clients/python.md
master
redis
[ 0.02581377513706684, 0.09707470238208771, 0.06316043436527252, 0.07062838226556778, -0.019018493592739105, -0.010218541137874126, -0.011990784667432308, 0.06188138201832771, 0.05374402925372124, -0.02967754192650318, -0.011356410570442677, -0.016305001452565193, 0.03498426824808121, 0.0150...
0.038226
Install Redis and the Redis client, then connect your .NET application to a Redis database. ## NRedisStack [NRedisStack](https://github.com/redis/NRedisStack) is a .NET client for Redis. `NredisStack` requires a running Redis or [Redis Stack](https://redis.io/docs/getting-started/install-stack/) server. See [Getting st...
https://github.com/redis/redis-doc/blob/master/docs/connect/clients/dotnet.md
master
redis
[ -0.022103890776634216, -0.09424249827861786, -0.10827814042568207, -0.03919757530093193, -0.04785636067390442, -0.040641747415065765, 0.031283099204301834, 0.06418243050575256, -0.030936118215322495, 0.03868153691291809, -0.06524927914142609, 0.0010907126124948263, 0.05470454692840576, 0.0...
0.100504
for search and JSON commands. ```csharp var db = redis.GetDatabase(); var ft = db.FT(); var json = db.JSON(); ``` Let's create some test data to add to your database. ```csharp var user1 = new { name = "Paul John", email = "paul.john@example.com", age = 42, city = "London" }; var user2 = new { name = "Eden Zamir", emai...
https://github.com/redis/redis-doc/blob/master/docs/connect/clients/dotnet.md
master
redis
[ -0.0017704900819808245, -0.011889203451573849, -0.03908384591341019, 0.1002453863620758, -0.05949009954929352, -0.0031465888023376465, 0.038883332163095474, 0.03681951016187668, 0.02856602892279625, -0.05811622738838196, 0.011415695771574974, -0.04090685024857521, 0.07876291871070862, -0.0...
-0.019376
Install Redis and the Redis client, then connect your Node.js application to a Redis database. ## node-redis [node-redis](https://github.com/redis/node-redis) is a modern, high-performance Redis client for Node.js. `node-redis` requires a running Redis or [Redis Stack](https://redis.io/docs/getting-started/install-stac...
https://github.com/redis/redis-doc/blob/master/docs/connect/clients/nodejs.md
master
redis
[ -0.02727567031979561, -0.07684662938117981, -0.07480508834123611, 0.024723703041672707, -0.029817044734954834, -0.06102435290813446, -0.06905045360326767, 0.06819871068000793, -0.01238398626446724, 0.02501596324145794, -0.0718301311135292, 0.038327667862176895, 0.041508644819259644, -0.043...
0.082024
The client uses `reconnectStrategy` to decide when to attempt to reconnect. The default strategy is to calculate the delay before each attempt based on the attempt number `Math.min(retries \* 50, 500)`. You can customize this strategy by passing a supported value to `reconnectStrategy` option: 1. Define a callback `(re...
https://github.com/redis/redis-doc/blob/master/docs/connect/clients/nodejs.md
master
redis
[ -0.038624025881290436, -0.05419021099805832, -0.006796704139560461, 0.09320288151502609, -0.08300366252660751, 0.004738240968436003, 0.02398144081234932, 0.017989816144108772, 0.08339939266443253, -0.005892891902476549, -0.052235789597034454, 0.06569819897413254, -0.0007533708703704178, -0...
0.064267
Here, you will learn how to connect your application to a Redis database. If you're new to Redis, you might first want to [install Redis with Redis Stack and RedisInsight](/docs/getting-started/install-stack/). For more Redis topics, see [Using](/docs/manual/) and [Managing](/docs/management/) Redis. If you're ready to...
https://github.com/redis/redis-doc/blob/master/docs/connect/clients/_index.md
master
redis
[ -0.026450486853718758, -0.1296854317188263, -0.10122154653072357, -0.0020177054684609175, -0.06212761253118515, -0.05789940804243088, 0.015720661729574203, 0.06825561076402664, -0.04394957795739174, -0.007284275721758604, -0.04656479135155678, 0.041919197887182236, 0.076075978577137, -0.00...
0.135903
Install Redis and the Redis client, then connect your Java application to a Redis database. ## Jedis [Jedis](https://github.com/redis/jedis) is a Java client for Redis designed for performance and ease of use. ### Install To include `Jedis` as a dependency in your application, edit the dependency file, as follows. \* I...
https://github.com/redis/redis-doc/blob/master/docs/connect/clients/java/jedis.md
master
redis
[ -0.03551763668656349, -0.07640410214662552, -0.05662813410162926, -0.06642809510231018, 0.00583348935469985, -0.03844649717211723, -0.030701979994773865, 0.011416085995733738, 0.013734261505305767, -0.00819372944533825, 0.004325256682932377, 0.00021512644889298826, 0.03958193212747574, -0....
0.051945
in the previous section, use `JedisPool` or `JedisPooled` to create a connection pool. `JedisPooled`, added in Jedis version 4.0.0, provides capabilities similar to `JedisPool` but with a more straightforward API. A connection pool holds a specified number of connections, creates more connections when necessary, and te...
https://github.com/redis/redis-doc/blob/master/docs/connect/clients/java/jedis.md
master
redis
[ -0.023592589423060417, -0.05701013654470444, -0.08925807476043701, -0.021789314225316048, -0.06411239504814148, -0.028983047232031822, 0.055996935814619064, -0.029698608443140984, 0.04671498388051987, 0.018728598952293396, 0.04400178790092468, 0.00971261691302061, 0.053101472556591034, 0.0...
0.051479
when issuing commands (disconnect) - Any unknown server messages - Sentinel: can connect to sentinel but master is not monitored or all Sentinels are down. - MULTI or DISCARD command failed - Shard commands key hash check failed or no Reachable Shards - Retry deadline exceeded/number of attempts (Retry Command Executor...
https://github.com/redis/redis-doc/blob/master/docs/connect/clients/java/jedis.md
master
redis
[ 0.011046890169382095, -0.06983058899641037, -0.011377058923244476, 0.036518871784210205, -0.004611510317772627, -0.0893707126379013, -0.029250016435980797, -0.019896605983376503, 0.053185805678367615, 0.012423161417245865, -0.0313333123922348, 0.03131265565752983, 0.01762993074953556, 0.00...
0.09608
Install Redis and the Redis client, then connect your Lettuce application to a Redis database. ## Lettuce Lettuce offers a powerful and efficient way to interact with Redis through its asynchronous and reactive APIs. By leveraging these capabilities, you can build high-performance, scalable Java applications that make ...
https://github.com/redis/redis-doc/blob/master/docs/connect/clients/java/lettuce.md
master
redis
[ -0.0319584459066391, -0.0759415403008461, -0.047310370951890945, -0.035516805946826935, -0.030330825597047806, 0.0104694664478302, -0.06311051547527313, 0.06452228128910065, -0.018453335389494896, 0.005609831772744656, -0.027032960206270218, 0.014691350981593132, 0.037292659282684326, -0.0...
0.062585
Lettuce asynchronous connection methods. ```java package org.example; import io.lettuce.core.RedisClient; import io.lettuce.core.RedisURI; import io.lettuce.core.TransactionResult; import io.lettuce.core.api.StatefulRedisConnection; import io.lettuce.core.api.async.RedisAsyncCommands; import io.lettuce.core.codec.Strin...
https://github.com/redis/redis-doc/blob/master/docs/connect/clients/java/lettuce.md
master
redis
[ -0.029880601912736893, -0.041636720299720764, -0.09603244066238403, 0.0026714385021477938, -0.08277074992656708, -0.02849499322474003, 0.018777571618556976, -0.0022891319822520018, 0.023763636127114296, -0.003943486604839563, -0.015424604527652264, 0.0114390654489398, 0.021380912512540817, ...
0.072587
`SUBSCRIBE`, `UNSUBSCRIBE` and `PUBLISH` implement the [Publish/Subscribe messaging paradigm](http://en.wikipedia.org/wiki/Publish/subscribe) where (citing Wikipedia) senders (publishers) are not programmed to send their messages to specific receivers (subscribers). Rather, published messages are characterized into cha...
https://github.com/redis/redis-doc/blob/master/docs/interact/pubsub.md
master
redis
[ 0.002356095938012004, -0.12797163426876068, -0.05178603529930115, 0.013834996148943901, -0.036378730088472366, -0.05960891395807266, 0.017994090914726257, -0.023933570832014084, 0.061667341738939285, 0.008352004922926426, -0.031658515334129333, 0.07964417338371277, 0.07826648652553558, -0....
0.153087
numbers. Publishing on db 10, will be heard by a subscriber on db 1. If you need scoping of some kind, prefix the channels with the name of the environment (test, staging, production...). ## Wire protocol example ``` SUBSCRIBE first second \*3 $9 subscribe $5 first :1 \*3 $9 subscribe $6 second :2 ``` At this point, fr...
https://github.com/redis/redis-doc/blob/master/docs/interact/pubsub.md
master
redis
[ -0.04618855193257332, -0.08925064653158188, -0.05382947251200676, 0.03466525673866272, -0.05137110874056816, -0.06902124732732773, 0.06424978375434875, -0.06609530001878738, -0.023223670199513435, 0.021789247170090675, -0.02391042746603489, 0.005682666786015034, 0.10589233040809631, -0.015...
0.120327
implement sharded Pub/Sub. Sharded Pub/Sub helps to scale the usage of Pub/Sub in cluster mode. It restricts the propagation of messages to be within the shard of a cluster. Hence, the amount of data passing through the cluster bus is limited in comparison to global Pub/Sub where each message propagates to each node in...
https://github.com/redis/redis-doc/blob/master/docs/interact/pubsub.md
master
redis
[ 0.02288063056766987, -0.019330017268657684, 0.02536880038678646, -0.014109262265264988, -0.02181435190141201, -0.052162084728479385, 0.04009770601987839, -0.009079686366021633, 0.09194530546665192, 0.006194184999912977, -0.09092649817466736, 0.0305768009275198, 0.06838614493608475, 0.01492...
0.084191
Redis Transactions allow the execution of a group of commands in a single step, they are centered around the commands `MULTI`, `EXEC`, `DISCARD` and `WATCH`. Redis Transactions make two important guarantees: \* All the commands in a transaction are serialized and executed sequentially. A request sent by another client ...
https://github.com/redis/redis-doc/blob/master/docs/interact/transactions.md
master
redis
[ -0.042988963425159454, -0.053813591599464417, -0.08659256994724274, 0.016050703823566437, 0.03343234956264496, -0.07439576089382172, 0.03783749043941498, 0.007348410319536924, 0.13624341785907745, 0.0571146197617054, 0.044711947441101074, 0.09295899420976639, -0.0012254371540620923, -0.052...
0.139628
to execute the transaction returning an error during `EXEC`, discarding the transaction. > \*\*Note for Redis < 2.6.5:\*\* Prior to Redis 2.6.5 clients needed to detect errors occurring prior to `EXEC` by checking the return value of the queued command: if the command replies with QUEUED it was queued correctly, otherw...
https://github.com/redis/redis-doc/blob/master/docs/interact/transactions.md
master
redis
[ -0.04602127894759178, -0.005020106676965952, -0.03408029302954674, 0.033299002796411514, -0.08788664638996124, -0.06447120755910873, 0.07259060442447662, 0.017883146181702614, 0.03928264603018761, 0.04711908847093582, 0.03898878023028374, -0.007077328395098448, 0.029574064537882805, -0.036...
0.088815
instead of 12. Thanks to `WATCH` we are able to model the problem very well: ``` WATCH mykey val = GET mykey val = val + 1 MULTI SET mykey $val EXEC ``` Using the above code, if there are race conditions and another client modifies the result of `val` in the time between our call to `WATCH` and our call to `EXEC`, the ...
https://github.com/redis/redis-doc/blob/master/docs/interact/transactions.md
master
redis
[ -0.060145020484924316, -0.015982648357748985, -0.0755128413438797, -0.01742253638803959, -0.0380084291100502, -0.0270775705575943, 0.054824717342853546, -0.024387283250689507, 0.11151331663131714, 0.04515165835618973, 0.049737393856048584, 0.060589905828237534, 0.03466083109378815, -0.0987...
0.122746
Redis Functions is an API for managing code to be executed on the server. This feature, which became available in Redis 7, supersedes the use of [EVAL](/docs/manual/programmability/eval-intro) in prior versions of Redis. ## Prologue (or, what's wrong with Eval Scripts?) Prior versions of Redis made scripting available ...
https://github.com/redis/redis-doc/blob/master/docs/interact/programmability/functions-intro.md
master
redis
[ -0.05633964017033577, -0.026973219588398933, -0.07145237177610397, 0.026347825303673744, 0.053011514246463776, -0.1359397917985916, 0.031856145709753036, 0.009517446160316467, 0.09750886261463165, 0.0064974818378686905, -0.018728528171777725, 0.05096140131354332, 0.019922545179724693, -0.1...
0.125967
unique user-defined name, making it much easier to call and trace its execution. The design of Redis Functions also attempts to demarcate between the programming language used for writing functions and their management by the server. Lua, the only language interpreter that Redis presently support as an embedded executi...
https://github.com/redis/redis-doc/blob/master/docs/interact/programmability/functions-intro.md
master
redis
[ -0.09944574534893036, -0.061877187341451645, -0.07286181300878525, 0.012681412510573864, -0.0025453297421336174, -0.129643514752388, -0.021495796740055084, 0.04427700489759445, 0.022641412913799286, -0.06544622033834457, -0.04662302881479263, 0.012045400217175484, -0.013613223098218441, -0...
0.239097
functions registered ``` The error is expected, as there are no functions in the loaded library. Every library needs to include at least one registered function to load successfully. A registered function is named and acts as an entry point to the library. When the target execution engine handles the `FUNCTION LOAD` co...
https://github.com/redis/redis-doc/blob/master/docs/interact/programmability/functions-intro.md
master
redis
[ -0.10306800156831741, -0.07205197960138321, -0.07059869915246964, 0.030420027673244476, -0.03687050938606262, -0.07324142009019852, 0.05670543015003204, 0.0743420422077179, 0.007980172522366047, -0.09615769982337952, -0.019328614696860313, -0.03137543424963951, -0.018898434937000275, -0.07...
0.069958
file named \_mylib.lua\_ that consists of the library's definition, we can load it like so (without stripping the source code of helpful whitespaces): ```bash $ cat mylib.lua | redis-cli -x FUNCTION LOAD REPLACE ``` We've added the `REPLACE` modifier to the call to `FUNCTION LOAD` to tell Redis that we want to overwrit...
https://github.com/redis/redis-doc/blob/master/docs/interact/programmability/functions-intro.md
master
redis
[ -0.03359375521540642, -0.04324229434132576, -0.03814114257693291, -0.016835635527968407, -0.021321656182408333, -0.060884129256010056, 0.10654853284358978, 0.07428570091724396, 0.033406563103199005, -0.0354098305106163, -0.01262595597654581, 0.017615584656596184, 0.018969176337122917, -0.1...
0.060218
1) "name" 2) "my\_hlastmodified" 3) "description" 4) (nil) 5) "flags" 6) (empty array) ``` You can see that it is easy to update our library with new capabilities. ## Reusing code in the library On top of bundling functions together into database-managed software artifacts, libraries also facilitate code sharing. We ca...
https://github.com/redis/redis-doc/blob/master/docs/interact/programmability/functions-intro.md
master
redis
[ -0.06259512156248093, -0.04509442672133446, -0.060026656836271286, 0.0049683814868330956, 0.011824030429124832, -0.11809159070253372, 0.07101468741893768, 0.020828329026699066, -0.02100483700633049, -0.019739428535103798, 0.049297261983156204, -0.01183623168617487, 0.05048518255352974, -0....
0.057571
that can be loaded by Redis at startup. ## Function flags Redis needs to have some information about how a function is going to behave when executed, in order to properly enforce resource usage policies and maintain data consistency. For example, Redis needs to know that a certain function is read-only before permittin...
https://github.com/redis/redis-doc/blob/master/docs/interact/programmability/functions-intro.md
master
redis
[ -0.05852533504366875, -0.05936071276664734, -0.0959586575627327, 0.04346979781985283, 0.005788546986877918, -0.06949348747730255, 0.024497468024492264, 0.034598227590322495, 0.026951728388667107, 0.010708579793572426, -0.035849325358867645, 0.05594617500901222, 0.02723780833184719, -0.0630...
0.158384
Starting with version 3.2 Redis includes a complete Lua debugger, that can be used in order to make the task of writing complex Redis scripts much simpler. The Redis Lua debugger, codenamed LDB, has the following important features: \* It uses a server-client model, so it's a remote debugger. The Redis server acts as t...
https://github.com/redis/redis-doc/blob/master/docs/interact/programmability/lua-debugging.md
master
redis
[ -0.07115960121154785, -0.10555107146501541, -0.044205717742443085, 0.017902756109833717, 0.015248950570821762, -0.1131722629070282, -0.01351137738674879, 0.029749497771263123, 0.0455845445394516, 0.01135837472975254, 0.038405001163482666, 0.03718532621860504, -0.047844622284173965, -0.0962...
0.071601
and stop again. [n]ext Alias for step. [c]ontinue Run till next breakpoint. [l]ist List source code around current line. [l]ist [line] List source code around [line]. line = 0 means: current position. [l]ist [line] [ctx] In this form [ctx] specifies how many lines to show before/after [line]. [w]hole List all source co...
https://github.com/redis/redis-doc/blob/master/docs/interact/programmability/lua-debugging.md
master
redis
[ -0.10414154082536697, 0.0017546646995469928, -0.03640475124120712, -0.007777791004627943, -0.021839380264282227, -0.021815845742821693, 0.04110216349363327, 0.08070514351129532, -0.07801207154989243, -0.004784795921295881, -0.017946094274520874, 0.01332206279039383, -0.009413042105734348, ...
0.081397
like declaration of local variables or comments, will not work. The breakpoint will be added but since this part of the script will never be executed, the program will never stop. ## Dynamic breakpoints Using the `breakpoint` command it is possible to add breakpoints into specific lines. However sometimes we want to st...
https://github.com/redis/redis-doc/blob/master/docs/interact/programmability/lua-debugging.md
master
redis
[ -0.03941724821925163, -0.09139080345630646, -0.02006031572818756, 0.05433764308691025, -0.004849889315664768, -0.027308790013194084, 0.044583093374967575, 0.083126962184906, -0.02818262204527855, -0.0003219390055164695, 0.035653725266456604, 0.00395608227699995, -0.038561005145311356, -0.0...
0.013166
`eval` command executes small pieces of Lua scripts **outside the context of the current call frame** (evaluating inside the context of the current call frame is not possible with the current Lua internals). However you can use this command in order to test Lua functions. ``` lua debugger> e redis.sha1hex('foo') "0beec...
https://github.com/redis/redis-doc/blob/master/docs/interact/programmability/lua-debugging.md
master
redis
[ -0.05060959979891777, -0.05518872290849686, -0.07243520021438599, 0.021424120292067528, 0.04213450849056244, -0.13036184012889862, 0.026623200625181198, 0.03865724056959152, 0.01754596456885338, -0.006148568820208311, 0.01096018124371767, -0.013231552205979824, -0.0433344729244709, -0.0543...
0.056293
Redis lets users upload and execute Lua scripts on the server. Scripts can employ programmatic control structures and use most of the [commands](/commands) while executing to access the database. Because scripts execute in the server, reading and writing data from scripts is very efficient. Redis guarantees the script'...
https://github.com/redis/redis-doc/blob/master/docs/interact/programmability/eval-intro.md
master
redis
[ -0.06225200742483139, -0.04772438108921051, -0.05560889467597008, 0.04548124596476555, 0.0005841927486471832, -0.11444813758134842, -0.028217852115631104, 0.07265032827854156, 0.06886980682611465, 0.03608091175556183, 0.0032573258504271507, 0.09397277981042862, 0.007394328247755766, -0.111...
0.195714
those that aren't. While key names in Redis are just strings, unlike any other string values, these represent keys in the database. The name of a key is a fundamental concept in Redis and is the basis for operating the Redis Cluster. \*\*Important:\*\* to ensure the correct execution of scripts, both in standalone and ...
https://github.com/redis/redis-doc/blob/master/docs/interact/programmability/eval-intro.md
master
redis
[ -0.055364858359098434, -0.05012349411845207, -0.08198779076337814, 0.05701887980103493, -0.036021698266267776, -0.08213429898023605, 0.05771692097187042, 0.03309452906250954, 0.032611340284347534, -0.014535891823470592, 0.03633393347263336, -0.0016514572780579329, 0.06684581190347672, -0.1...
0.150444
digest sum of a script uniquely identifies it in the cache. You can verify this behavior by running `EVAL` and calling `INFO` afterward. You'll notice that the \_used\_memory\_scripts\_eval\_ and \_number\_of\_cached\_scripts\_ metrics grow with every new script that's executed. As mentioned above, dynamically-generate...
https://github.com/redis/redis-doc/blob/master/docs/interact/programmability/eval-intro.md
master
redis
[ 0.004123029764741659, 0.014431812800467014, -0.05829230323433876, 0.0446317158639431, -0.016389185562729836, -0.10268545150756836, 0.047601498663425446, -0.021044034510850906, 0.11520452797412872, -0.0004347885260358453, -0.06218283995985985, 0.04061666876077652, 0.02498192898929119, -0.08...
0.07655
between two different commands: \* The connection we have with the server is persistent and was never closed so far. \* The client explicitly checks the `run\_id` field in the `INFO` command to ensure the server was not restarted and is still the same process. Practically speaking, it is much simpler for the client to ...
https://github.com/redis/redis-doc/blob/master/docs/interact/programmability/eval-intro.md
master
redis
[ -0.05678032711148262, -0.02584642916917801, -0.08073432743549347, 0.017285699024796486, -0.023510606959462166, -0.08388920873403549, 0.035576753318309784, -0.0016735225217416883, 0.07599520683288574, -0.014455346390604973, -0.025971638038754463, 0.09974238276481628, 0.004955771844834089, -...
0.146958
Verbatim script replication was the only mode supported until Redis 3.2, in which effects replication was added. The \_lua-replicate-commands\_ configuration directive and [`redis.replicate\_commands()`](/topics/lua-api#redis.replicate\_commands) Lua API can be used to enable it. In Redis 5.0, effects replication becam...
https://github.com/redis/redis-doc/blob/master/docs/interact/programmability/eval-intro.md
master
redis
[ -0.09859315305948257, -0.13949833810329437, -0.046910010278224945, 0.06528007239103317, 0.009140397422015667, -0.05513777583837509, -0.02837701141834259, -0.04004501923918724, 0.019675657153129578, 0.08699966967105865, 0.018559331074357033, 0.027239231392741203, 0.046032365411520004, -0.04...
0.084783
invoked by Lua scripts). Normally replicating scripts instead of the effects of the scripts makes sense, however not in all the cases. So starting with Redis 3.2, the scripting engine is able to, alternatively, replicate the sequence of write commands resulting from the script execution, instead of replication the scri...
https://github.com/redis/redis-doc/blob/master/docs/interact/programmability/eval-intro.md
master
redis
[ -0.10646461695432663, -0.09887173771858215, -0.06314530968666077, 0.03925476223230362, -0.02428652159869671, -0.10738982260227203, 0.01900804415345192, -0.0031626312993466854, 0.07882213592529297, 0.054858848452568054, 0.02461419254541397, 0.07213298976421356, 0.06697410345077515, -0.09475...
0.117842
-1 1) "0.74509509873814" 2) "0.87390407681181" 3) "0.36876626981831" 4) "0.6921941534114" 5) "0.7857992587545" 6) "0.57730350670279" 7) "0.87046522734243" 8) "0.09637165539729" 9) "0.74990198051087" 10) "0.17082803611217" ``` To make the script both deterministic and still have it produce different random elements, we ...
https://github.com/redis/redis-doc/blob/master/docs/interact/programmability/eval-intro.md
master
redis
[ -0.11082341521978378, -0.0318215973675251, -0.08172470331192017, 0.00414647813886404, 0.022349920123815536, -0.11773157864809036, 0.11159088462591171, 0.0156343262642622, 0.016866564750671387, 0.003977462649345398, 0.03487183898687363, -0.01771068200469017, 0.02735464833676815, -0.10523664...
0.001226
x = redis.call('get','x') return x ``` Note that as soon as Redis sees the `#!` comment, it'll treat the script as if it declares flags, even if no flags are defined, it still has a different set of defaults compared to a script without a `#!` line. Another difference is that scripts without `#!` can run commands that ...
https://github.com/redis/redis-doc/blob/master/docs/interact/programmability/eval-intro.md
master
redis
[ -0.030137915164232254, -0.050920937210321426, -0.07561385631561279, 0.03352884575724602, 0.030745264142751694, -0.07392679154872894, 0.08088655024766922, 0.01252731028944254, 0.03237353637814522, -0.07221104949712753, 0.046509869396686554, 0.029284009709954262, -0.0008562074508517981, -0.0...
0.065372
Redis includes an embedded [Lua 5.1](https://www.lua.org/) interpreter. The interpreter runs user-defined [ephemeral scripts](/topics/eval-intro) and [functions](/topics/functions-intro). Scripts run in a sandboxed context and can only access specific Lua packages. This page describes the packages and APIs available in...
https://github.com/redis/redis-doc/blob/master/docs/interact/programmability/lua-api.md
master
redis
[ -0.04934467002749443, -0.04871683195233345, -0.07100096344947815, 0.007360952440649271, 0.07224872708320618, -0.11614252626895905, -0.00020953906641807407, 0.051494479179382324, 0.06073767691850662, -0.023114100098609924, 0.02176271192729473, 0.07109451293945312, -0.017920423299074173, -0....
0.155599
programmatically-generated names or based on the contents of data structures stored in the database. The \_KEYS\_ global variable is available only for [ephemeral scripts](/topics/eval-intro). It is pre-populated with all key name input arguments. ### The \_ARGV\_ global variable \* Since version: 2.6.0 \* Available in...
https://github.com/redis/redis-doc/blob/master/docs/interact/programmability/lua-api.md
master
redis
[ -0.03551479056477547, -0.06982308626174927, -0.11121182143688202, 0.05380554497241974, -0.030541634187102318, -0.0860433429479599, 0.07319874316453934, 0.021757621318101883, 0.012532172724604607, -0.02479497902095318, 0.026355162262916565, -0.009597687982022762, 0.03369951248168945, -0.099...
0.12932
for returning an error reply from scripts: ``` redis> EVAL "return { err = 'ERR My very special table error' }" 0 (error) ERR My very special table error redis> EVAL "return redis.error\_reply('ERR My very special reply error')" 0 (error) ERR My very special reply error ``` For returning Redis status replies refer to [...
https://github.com/redis/redis-doc/blob/master/docs/interact/programmability/lua-api.md
master
redis
[ -0.03989680856466293, -0.005881678778678179, 0.0070911007933318615, 0.04608208313584328, 0.004195463843643665, -0.07749314606189728, 0.07685759663581848, 0.04663394019007683, -0.014971188269555569, -0.0020909574814140797, -0.014231797307729721, -0.045957792550325394, 0.06548904627561569, -...
0.0698
verbatim, meaning that the scripts' source code was sent for execution by replicas and stored in the AOF. An alternative replication mode added in version 3.2.0 allows replicating only the scripts' effects. As of Redis version 7.0, script replication is no longer supported, and the only replication mode available is sc...
https://github.com/redis/redis-doc/blob/master/docs/interact/programmability/lua-api.md
master
redis
[ -0.05800357460975647, -0.0825633630156517, -0.06185610592365265, 0.05579235777258873, 0.0507652685046196, -0.0510152131319046, 0.018384966999292374, -0.037786632776260376, 0.08942917734384537, 0.059538476169109344, -0.009273933246731758, 0.07387957721948624, 0.07254014909267426, -0.1235892...
0.143033
\* Available in scripts: yes \* Available in functions: yes This function is used for checking if the current user running the script has [ACL](/topics/acl) permissions to execute the given command with the given arguments. The return value is a boolean `true` in case the current user has permissions to execute the com...
https://github.com/redis/redis-doc/blob/master/docs/interact/programmability/lua-api.md
master
redis
[ -0.09826753288507462, -0.039785176515579224, -0.10790866613388062, 0.026864109560847282, -0.027681954205036163, -0.07353641092777252, 0.09396415203809738, 0.04292165860533714, 0.003330961801111698, -0.048516109585762024, -0.009294524788856506, 0.03132938593626022, -0.007385428994894028, -0...
0.162123
`allow-oom`: use this flag to allow a script to execute when the server is out of memory (OOM). Unless used, Redis will deny the execution of flagged scripts (Functions and Eval scripts with [shebang](/topics/eval-intro#eval-flags)) when in an OOM state. Furthermore, when you use this flag, the script can call any Redi...
https://github.com/redis/redis-doc/blob/master/docs/interact/programmability/lua-api.md
master
redis
[ -0.054195061326026917, -0.003929153550416231, -0.12211066484451294, 0.06266556680202484, 0.06821189820766449, -0.08945769816637039, -0.014856857247650623, -0.02478494495153427, 0.013633571565151215, 0.00024280635989271104, -0.005061801057308912, 0.08893848955631256, -0.016239790245890617, ...
0.1851
`redis.call()` and `redis.pcall()`) to Lua data types depends on the Redis Serialization Protocol version used by the script. The default protocol version during script executions is RESP2. The script may switch the replies' protocol versions by calling the `redis.setresp()` function. Type conversion from a script's re...
https://github.com/redis/redis-doc/blob/master/docs/interact/programmability/lua-api.md
master
redis
[ -0.03146845102310181, -0.05909375101327896, -0.045716121792793274, 0.016604604199528694, -0.03665132820606232, -0.10550683736801147, 0.033833183348178864, 0.07065010070800781, 0.0053150951862335205, -0.0010396207217127085, -0.030440598726272583, 0.01625748537480831, -0.019625568762421608, ...
0.063803
(integer) 2 3) (integer) 3 4) "foo" ``` As you can see, the float value of \_3.333\_ gets converted to an integer \_3\_, the \_somekey\_ key and its value are omitted, and the string "bar" isn't returned as there is a `nil` value that precedes it. ### RESP3 to Lua type conversion [RESP3](https://github.com/redis/redis-...
https://github.com/redis/redis-doc/blob/master/docs/interact/programmability/lua-api.md
master
redis
[ -0.03140877187252045, -0.01740170083940029, -0.09774012118577957, -0.013381432741880417, -0.030999839305877686, -0.06636054813861847, 0.04909369722008705, 0.02144569531083107, 0.03350085765123367, -0.024510860443115234, -0.014408132061362267, 0.009811334311962128, 0.02725154533982277, -0.0...
0.100185
That means, for example, that returning the RESP3 map type to a RESP2 connection will result in the reply being converted to a flat RESP2 array that consists of alternating field names and their values, rather than a RESP3 map. ## Additional notes about scripting ### Using `SELECT` inside scripts You can call the `SELE...
https://github.com/redis/redis-doc/blob/master/docs/interact/programmability/lua-api.md
master
redis
[ -0.04829169437289238, -0.08021091669797897, -0.0331641361117363, 0.03359398618340492, 0.024665910750627518, -0.07836820930242538, 0.013704081997275352, 0.04120812937617302, 0.02869013510644436, 0.01249780971556902, 0.008298450149595737, 0.06609908491373062, 0.010797249153256416, -0.0918279...
0.087593
a struct. It accepts a [\_struct\_ format string](#struct-formats) as its only argument. Usage example: ``` redis> EVAL "return struct.size('HH')" 0 (integer) 4 ``` ### \_cjson\_ library \* Since version: 2.6.0 \* Available in scripts: yes \* Available in functions: yes The \_cjson\_ library provides fast [JSON](https:...
https://github.com/redis/redis-doc/blob/master/docs/interact/programmability/lua-api.md
master
redis
[ -0.07900869846343994, -0.0024147825315594673, -0.07653435319662094, 0.05469142645597458, 0.0031863776966929436, -0.0696609616279602, 0.010156345553696156, 0.05972908064723015, 0.03862767666578293, -0.07313968986272812, -0.002280713524669409, 0.01065816916525364, -0.10921866446733475, 0.052...
0.100861
Redis provides a programming interface that lets you execute custom scripts on the server itself. In Redis 7 and beyond, you can use [Redis Functions](/docs/manual/programmability/functions-intro) to manage and run your scripts. In Redis 6.2 and below, you use [Lua scripting with the EVAL command](/docs/manual/programm...
https://github.com/redis/redis-doc/blob/master/docs/interact/programmability/_index.md
master
redis
[ -0.057997364550828934, -0.046897031366825104, -0.08376790583133698, 0.02064819075167179, -0.00470940675586462, -0.11198637634515762, 0.03734571114182472, 0.06275278329849243, 0.0038153750356286764, -0.002580178203061223, -0.03064553439617157, 0.044616859406232834, 0.014480605721473694, -0....
0.191924