Redis.phan_php 151 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153
  1. <?php
  2. /**
  3. * Helper autocomplete for php redis extension
  4. *
  5. * @author Max Kamashev <max.kamashev@gmail.com>
  6. * @link https://github.com/ukko/phpredis-phpdoc
  7. */
  8. class Redis
  9. {
  10. const AFTER = 'after';
  11. const BEFORE = 'before';
  12. /**
  13. * Options
  14. */
  15. const OPT_SERIALIZER = 1;
  16. const OPT_PREFIX = 2;
  17. const OPT_READ_TIMEOUT = 3;
  18. const OPT_SCAN = 4;
  19. const OPT_SLAVE_FAILOVER = 5;
  20. /**
  21. * Cluster options
  22. */
  23. const FAILOVER_NONE = 0;
  24. const FAILOVER_ERROR = 1;
  25. const FAILOVER_DISTRIBUTE = 2;
  26. /**
  27. * SCAN options
  28. */
  29. const SCAN_NORETRY = 0;
  30. const SCAN_RETRY = 1;
  31. /**
  32. * Serializers
  33. */
  34. const SERIALIZER_NONE = 0;
  35. const SERIALIZER_PHP = 1;
  36. const SERIALIZER_IGBINARY = 2;
  37. const SERIALIZER_MSGPACK = 3;
  38. const SERIALIZER_JSON = 4;
  39. /**
  40. * Multi
  41. */
  42. const ATOMIC = 0;
  43. const MULTI = 1;
  44. const PIPELINE = 2;
  45. /**
  46. * Type
  47. */
  48. const REDIS_NOT_FOUND = 0;
  49. const REDIS_STRING = 1;
  50. const REDIS_SET = 2;
  51. const REDIS_LIST = 3;
  52. const REDIS_ZSET = 4;
  53. const REDIS_HASH = 5;
  54. /**
  55. * Creates a Redis client
  56. *
  57. * @example $redis = new Redis();
  58. */
  59. public function __construct()
  60. {
  61. }
  62. /**
  63. * Connects to a Redis instance.
  64. *
  65. * @param string $host can be a host, or the path to a unix domain socket
  66. * @param int $port optional
  67. * @param float $timeout value in seconds (optional, default is 0.0 meaning unlimited)
  68. * @param null $reserved should be null if $retryInterval is specified
  69. * @param int $retryInterval retry interval in milliseconds.
  70. * @param float $readTimeout value in seconds (optional, default is 0 meaning unlimited)
  71. *
  72. * @return bool TRUE on success, FALSE on error
  73. *
  74. * @example
  75. * <pre>
  76. * $redis->connect('127.0.0.1', 6379);
  77. * $redis->connect('127.0.0.1'); // port 6379 by default
  78. * $redis->connect('127.0.0.1', 6379, 2.5); // 2.5 sec timeout.
  79. * $redis->connect('/tmp/redis.sock'); // unix domain socket.
  80. * </pre>
  81. */
  82. public function connect(
  83. $host,
  84. $port = 6379,
  85. $timeout = 0.0,
  86. $reserved = null,
  87. $retryInterval = 0,
  88. $readTimeout = 0.0
  89. ) {
  90. }
  91. /**
  92. * Connects to a Redis instance.
  93. *
  94. * @param string $host can be a host, or the path to a unix domain socket
  95. * @param int $port optional
  96. * @param float $timeout value in seconds (optional, default is 0.0 meaning unlimited)
  97. * @param null $reserved should be null if $retry_interval is specified
  98. * @param int $retryInterval retry interval in milliseconds.
  99. * @param float $readTimeout value in seconds (optional, default is 0 meaning unlimited)
  100. *
  101. * @return bool TRUE on success, FALSE on error
  102. *
  103. * @see connect()
  104. * @deprecated use Redis::connect()
  105. */
  106. public function open(
  107. $host,
  108. $port = 6379,
  109. $timeout = 0.0,
  110. $reserved = null,
  111. $retryInterval = 0,
  112. $readTimeout = 0.0
  113. ) {
  114. }
  115. /**
  116. * A method to determine if a phpredis object thinks it's connected to a server
  117. *
  118. * @return bool Returns TRUE if phpredis thinks it's connected and FALSE if not
  119. */
  120. public function isConnected()
  121. {
  122. }
  123. /**
  124. * Retrieve our host or unix socket that we're connected to
  125. *
  126. * @return string|bool The host or unix socket we're connected to or FALSE if we're not connected
  127. */
  128. public function getHost()
  129. {
  130. }
  131. /**
  132. * Get the port we're connected to
  133. *
  134. * @return int|bool Returns the port we're connected to or FALSE if we're not connected
  135. */
  136. public function getPort()
  137. {
  138. }
  139. /**
  140. * Get the database number phpredis is pointed to
  141. *
  142. * @return int|bool Returns the database number (int) phpredis thinks it's pointing to
  143. * or FALSE if we're not connected
  144. */
  145. public function getDbNum()
  146. {
  147. }
  148. /**
  149. * Get the (write) timeout in use for phpredis
  150. *
  151. * @return float|bool The timeout (DOUBLE) specified in our connect call or FALSE if we're not connected
  152. */
  153. public function getTimeout()
  154. {
  155. }
  156. /**
  157. * Get the read timeout specified to phpredis or FALSE if we're not connected
  158. *
  159. * @return float|bool Returns the read timeout (which can be set using setOption and Redis::OPT_READ_TIMEOUT)
  160. * or FALSE if we're not connected
  161. */
  162. public function getReadTimeout()
  163. {
  164. }
  165. /**
  166. * Gets the persistent ID that phpredis is using
  167. *
  168. * @return string|null|bool Returns the persistent id phpredis is using
  169. * (which will only be set if connected with pconnect),
  170. * NULL if we're not using a persistent ID,
  171. * and FALSE if we're not connected
  172. */
  173. public function getPersistentID()
  174. {
  175. }
  176. /**
  177. * Get the password used to authenticate the phpredis connection
  178. *
  179. * @return string|null|bool Returns the password used to authenticate a phpredis session or NULL if none was used,
  180. * and FALSE if we're not connected
  181. */
  182. public function getAuth()
  183. {
  184. }
  185. /**
  186. * Connects to a Redis instance or reuse a connection already established with pconnect/popen.
  187. *
  188. * The connection will not be closed on close or end of request until the php process ends.
  189. * So be patient on to many open FD's (specially on redis server side) when using persistent connections on
  190. * many servers connecting to one redis server.
  191. *
  192. * Also more than one persistent connection can be made identified by either host + port + timeout
  193. * or host + persistentId or unix socket + timeout.
  194. *
  195. * This feature is not available in threaded versions. pconnect and popen then working like their non persistent
  196. * equivalents.
  197. *
  198. * @param string $host can be a host, or the path to a unix domain socket
  199. * @param int $port optional
  200. * @param float $timeout value in seconds (optional, default is 0 meaning unlimited)
  201. * @param string $persistentId identity for the requested persistent connection
  202. * @param int $retryInterval retry interval in milliseconds.
  203. * @param float $readTimeout value in seconds (optional, default is 0 meaning unlimited)
  204. *
  205. * @return bool TRUE on success, FALSE on ertcnror.
  206. *
  207. * @example
  208. * <pre>
  209. * $redis->pconnect('127.0.0.1', 6379);
  210. *
  211. * // port 6379 by default - same connection like before
  212. * $redis->pconnect('127.0.0.1');
  213. *
  214. * // 2.5 sec timeout and would be another connection than the two before.
  215. * $redis->pconnect('127.0.0.1', 6379, 2.5);
  216. *
  217. * // x is sent as persistent_id and would be another connection than the three before.
  218. * $redis->pconnect('127.0.0.1', 6379, 2.5, 'x');
  219. *
  220. * // unix domain socket - would be another connection than the four before.
  221. * $redis->pconnect('/tmp/redis.sock');
  222. * </pre>
  223. */
  224. public function pconnect(
  225. $host,
  226. $port = 6379,
  227. $timeout = 0.0,
  228. $persistentId = null,
  229. $retryInterval = 0,
  230. $readTimeout = 0.0
  231. ) {
  232. }
  233. /**
  234. * @param string $host
  235. * @param int $port
  236. * @param float $timeout
  237. * @param string $persistentId
  238. * @param int $retryInterval
  239. * @param float $readTimeout
  240. *
  241. * @return bool
  242. *
  243. * @deprecated use Redis::pconnect()
  244. * @see pconnect()
  245. */
  246. public function popen(
  247. $host,
  248. $port = 6379,
  249. $timeout = 0.0,
  250. $persistentId = '',
  251. $retryInterval = 0,
  252. $readTimeout = 0.0
  253. ) {
  254. }
  255. /**
  256. * Disconnects from the Redis instance.
  257. *
  258. * Note: Closing a persistent connection requires PhpRedis >= 4.2.0
  259. *
  260. * @since >= 4.2 Closing a persistent connection requires PhpRedis
  261. *
  262. * @return bool TRUE on success, FALSE on error
  263. */
  264. public function close()
  265. {
  266. }
  267. /**
  268. * Swap one Redis database with another atomically
  269. *
  270. * Note: Requires Redis >= 4.0.0
  271. *
  272. * @param int $db1
  273. * @param int $db2
  274. *
  275. * @return bool TRUE on success and FALSE on failure
  276. *
  277. * @link https://redis.io/commands/swapdb
  278. * @since >= 4.0
  279. * @example
  280. * <pre>
  281. * // Swaps DB 0 with DB 1 atomically
  282. * $redis->swapdb(0, 1);
  283. * </pre>
  284. */
  285. public function swapdb(int $db1, int $db2)
  286. {
  287. }
  288. /**
  289. * Set client option
  290. *
  291. * @param int $option option name
  292. * @param mixed $value option value
  293. *
  294. * @return bool TRUE on success, FALSE on error
  295. *
  296. * @example
  297. * <pre>
  298. * $redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_NONE); // don't serialize data
  299. * $redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_PHP); // use built-in serialize/unserialize
  300. * $redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_IGBINARY); // use igBinary serialize/unserialize
  301. * $redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_MSGPACK); // Use msgpack serialize/unserialize
  302. * $redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_JSON); // Use json serialize/unserialize
  303. *
  304. * $redis->setOption(Redis::OPT_PREFIX, 'myAppName:'); // use custom prefix on all keys
  305. *
  306. * // Options for the SCAN family of commands, indicating whether to abstract
  307. * // empty results from the user. If set to SCAN_NORETRY (the default), phpredis
  308. * // will just issue one SCAN command at a time, sometimes returning an empty
  309. * // array of results. If set to SCAN_RETRY, phpredis will retry the scan command
  310. * // until keys come back OR Redis returns an iterator of zero
  311. * $redis->setOption(Redis::OPT_SCAN, Redis::SCAN_NORETRY);
  312. * $redis->setOption(Redis::OPT_SCAN, Redis::SCAN_RETRY);
  313. * </pre>
  314. */
  315. public function setOption($option, $value)
  316. {
  317. }
  318. /**
  319. * Get client option
  320. *
  321. * @param int $option parameter name
  322. *
  323. * @return mixed|null Parameter value
  324. *
  325. * @see setOption()
  326. * @example
  327. * // return option value
  328. * $redis->getOption(Redis::OPT_SERIALIZER);
  329. */
  330. public function getOption($option)
  331. {
  332. }
  333. /**
  334. * Check the current connection status
  335. *
  336. * @return string STRING: +PONG on success.
  337. * Throws a RedisException object on connectivity error, as described above.
  338. * @throws RedisException
  339. * @link https://redis.io/commands/ping
  340. */
  341. public function ping()
  342. {
  343. }
  344. /**
  345. * Echo the given string
  346. *
  347. * @param string $message
  348. *
  349. * @return string Returns message
  350. *
  351. * @link https://redis.io/commands/echo
  352. */
  353. public function echo($message)
  354. {
  355. }
  356. /**
  357. * Get the value related to the specified key
  358. *
  359. * @param string $key
  360. *
  361. * @return string|mixed|bool If key didn't exist, FALSE is returned.
  362. * Otherwise, the value related to this key is returned
  363. *
  364. * @link https://redis.io/commands/get
  365. * @example
  366. * <pre>
  367. * $redis->set('key', 'hello');
  368. * $redis->get('key');
  369. *
  370. * // set and get with serializer
  371. * $redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_JSON);
  372. *
  373. * $redis->set('key', ['asd' => 'as', 'dd' => 123, 'b' => true]);
  374. * var_dump($redis->get('key'));
  375. * // Output:
  376. * array(3) {
  377. * 'asd' => string(2) "as"
  378. * 'dd' => int(123)
  379. * 'b' => bool(true)
  380. * }
  381. * </pre>
  382. */
  383. public function get($key)
  384. {
  385. }
  386. /**
  387. * Set the string value in argument as value of the key.
  388. *
  389. * @since If you're using Redis >= 2.6.12, you can pass extended options as explained in example
  390. *
  391. * @param string $key
  392. * @param string|mixed $value string if not used serializer
  393. * @param int|array $timeout [optional] Calling setex() is preferred if you want a timeout.<br>
  394. * Since 2.6.12 it also supports different flags inside an array. Example ['NX', 'EX' => 60]<br>
  395. * - EX seconds -- Set the specified expire time, in seconds.<br>
  396. * - PX milliseconds -- Set the specified expire time, in milliseconds.<br>
  397. * - PX milliseconds -- Set the specified expire time, in milliseconds.<br>
  398. * - NX -- Only set the key if it does not already exist.<br>
  399. * - XX -- Only set the key if it already exist.<br>
  400. * <pre>
  401. * // Simple key -> value set
  402. * $redis->set('key', 'value');
  403. *
  404. * // Will redirect, and actually make an SETEX call
  405. * $redis->set('key','value', 10);
  406. *
  407. * // Will set the key, if it doesn't exist, with a ttl of 10 seconds
  408. * $redis->set('key', 'value', ['nx', 'ex' => 10]);
  409. *
  410. * // Will set a key, if it does exist, with a ttl of 1000 miliseconds
  411. * $redis->set('key', 'value', ['xx', 'px' => 1000]);
  412. * </pre>
  413. *
  414. * @return bool TRUE if the command is successful
  415. *
  416. * @link https://redis.io/commands/set
  417. */
  418. public function set($key, $value, $timeout = null)
  419. {
  420. }
  421. /**
  422. * Set the string value in argument as value of the key, with a time to live.
  423. *
  424. * @param string $key
  425. * @param int $ttl
  426. * @param string|mixed $value
  427. *
  428. * @return bool TRUE if the command is successful
  429. *
  430. * @link https://redis.io/commands/setex
  431. * @example $redis->setex('key', 3600, 'value'); // sets key → value, with 1h TTL.
  432. */
  433. public function setex($key, $ttl, $value)
  434. {
  435. }
  436. /**
  437. * Set the value and expiration in milliseconds of a key.
  438. *
  439. * @see setex()
  440. * @param string $key
  441. * @param int $ttl, in milliseconds.
  442. * @param string|mixed $value
  443. *
  444. * @return bool TRUE if the command is successful
  445. *
  446. * @link https://redis.io/commands/psetex
  447. * @example $redis->psetex('key', 1000, 'value'); // sets key → value, with 1sec TTL.
  448. */
  449. public function psetex($key, $ttl, $value)
  450. {
  451. }
  452. /**
  453. * Set the string value in argument as value of the key if the key doesn't already exist in the database.
  454. *
  455. * @param string $key
  456. * @param string|mixed $value
  457. *
  458. * @return bool TRUE in case of success, FALSE in case of failure
  459. *
  460. * @link https://redis.io/commands/setnx
  461. * @example
  462. * <pre>
  463. * $redis->setnx('key', 'value'); // return TRUE
  464. * $redis->setnx('key', 'value'); // return FALSE
  465. * </pre>
  466. */
  467. public function setnx($key, $value)
  468. {
  469. }
  470. /**
  471. * Remove specified keys.
  472. *
  473. * @param int|string|array $key1 An array of keys, or an undefined number of parameters, each a key: key1 key2 key3 ... keyN
  474. * @param int|string ...$otherKeys
  475. *
  476. * @return int Number of keys deleted
  477. *
  478. * @link https://redis.io/commands/del
  479. * @example
  480. * <pre>
  481. * $redis->set('key1', 'val1');
  482. * $redis->set('key2', 'val2');
  483. * $redis->set('key3', 'val3');
  484. * $redis->set('key4', 'val4');
  485. *
  486. * $redis->del('key1', 'key2'); // return 2
  487. * $redis->del(['key3', 'key4']); // return 2
  488. * </pre>
  489. */
  490. public function del($key1, ...$otherKeys)
  491. {
  492. }
  493. /**
  494. * @see del()
  495. * @deprecated use Redis::del()
  496. *
  497. * @param string|string[] $key1
  498. * @param string $key2
  499. * @param string $key3
  500. *
  501. * @return int Number of keys deleted
  502. */
  503. public function delete($key1, $key2 = null, $key3 = null)
  504. {
  505. }
  506. /**
  507. * Delete a key asynchronously in another thread. Otherwise it is just as DEL, but non blocking.
  508. *
  509. * @see del()
  510. * @param string|string[] $key1
  511. * @param string $key2
  512. * @param string $key3
  513. *
  514. * @return int Number of keys unlinked.
  515. *
  516. * @link https://redis.io/commands/unlink
  517. * @example
  518. * <pre>
  519. * $redis->set('key1', 'val1');
  520. * $redis->set('key2', 'val2');
  521. * $redis->set('key3', 'val3');
  522. * $redis->set('key4', 'val4');
  523. * $redis->unlink('key1', 'key2'); // return 2
  524. * $redis->unlink(array('key3', 'key4')); // return 2
  525. * </pre>
  526. */
  527. public function unlink($key1, $key2 = null, $key3 = null)
  528. {
  529. }
  530. /**
  531. * Enter and exit transactional mode.
  532. *
  533. * @param int $mode Redis::MULTI|Redis::PIPELINE
  534. * Defaults to Redis::MULTI.
  535. * A Redis::MULTI block of commands runs as a single transaction;
  536. * a Redis::PIPELINE block is simply transmitted faster to the server, but without any guarantee of atomicity.
  537. * discard cancels a transaction.
  538. *
  539. * @return Redis returns the Redis instance and enters multi-mode.
  540. * Once in multi-mode, all subsequent method calls return the same object until exec() is called.
  541. *
  542. * @link https://redis.io/commands/multi
  543. * @example
  544. * <pre>
  545. * $ret = $redis->multi()
  546. * ->set('key1', 'val1')
  547. * ->get('key1')
  548. * ->set('key2', 'val2')
  549. * ->get('key2')
  550. * ->exec();
  551. *
  552. * //$ret == array (
  553. * // 0 => TRUE,
  554. * // 1 => 'val1',
  555. * // 2 => TRUE,
  556. * // 3 => 'val2');
  557. * </pre>
  558. */
  559. public function multi($mode = Redis::MULTI)
  560. {
  561. }
  562. /**
  563. * @return void|array
  564. *
  565. * @see multi()
  566. * @link https://redis.io/commands/exec
  567. */
  568. public function exec()
  569. {
  570. }
  571. /**
  572. * @see multi()
  573. * @link https://redis.io/commands/discard
  574. */
  575. public function discard()
  576. {
  577. }
  578. /**
  579. * Watches a key for modifications by another client. If the key is modified between WATCH and EXEC,
  580. * the MULTI/EXEC transaction will fail (return FALSE). unwatch cancels all the watching of all keys by this client.
  581. * @param string|string[] $key a list of keys
  582. *
  583. * @return void
  584. *
  585. * @link https://redis.io/commands/watch
  586. * @example
  587. * <pre>
  588. * $redis->watch('x');
  589. * // long code here during the execution of which other clients could well modify `x`
  590. * $ret = $redis->multi()
  591. * ->incr('x')
  592. * ->exec();
  593. * // $ret = FALSE if x has been modified between the call to WATCH and the call to EXEC.
  594. * </pre>
  595. */
  596. public function watch($key)
  597. {
  598. }
  599. /**
  600. * @see watch()
  601. * @link https://redis.io/commands/unwatch
  602. */
  603. public function unwatch()
  604. {
  605. }
  606. /**
  607. * Subscribe to channels.
  608. *
  609. * Warning: this function will probably change in the future.
  610. *
  611. * @param string[] $channels an array of channels to subscribe
  612. * @param string|array $callback either a string or an array($instance, 'method_name').
  613. * The callback function receives 3 parameters: the redis instance, the channel name, and the message.
  614. *
  615. * @return mixed|null Any non-null return value in the callback will be returned to the caller.
  616. *
  617. * @link https://redis.io/commands/subscribe
  618. * @example
  619. * <pre>
  620. * function f($redis, $chan, $msg) {
  621. * switch($chan) {
  622. * case 'chan-1':
  623. * ...
  624. * break;
  625. *
  626. * case 'chan-2':
  627. * ...
  628. * break;
  629. *
  630. * case 'chan-2':
  631. * ...
  632. * break;
  633. * }
  634. * }
  635. *
  636. * $redis->subscribe(array('chan-1', 'chan-2', 'chan-3'), 'f'); // subscribe to 3 chans
  637. * </pre>
  638. */
  639. public function subscribe($channels, $callback)
  640. {
  641. }
  642. /**
  643. * Subscribe to channels by pattern
  644. *
  645. * @param array $patterns an array of glob-style patterns to subscribe
  646. * @param string|array $callback Either a string or an array with an object and method.
  647. * The callback will get four arguments ($redis, $pattern, $channel, $message)
  648. * @param mixed $chan Any non-null return value in the callback will be returned to the caller
  649. * @param string $msg
  650. *
  651. * @link https://redis.io/commands/psubscribe
  652. * @example
  653. * <pre>
  654. * function psubscribe($redis, $pattern, $chan, $msg) {
  655. * echo "Pattern: $pattern\n";
  656. * echo "Channel: $chan\n";
  657. * echo "Payload: $msg\n";
  658. * }
  659. * </pre>
  660. */
  661. public function psubscribe($patterns, $callback, $chan, $msg)
  662. {
  663. }
  664. /**
  665. * Publish messages to channels.
  666. *
  667. * Warning: this function will probably change in the future.
  668. *
  669. * @param string $channel a channel to publish to
  670. * @param string $message string
  671. *
  672. * @return int Number of clients that received the message
  673. *
  674. * @link https://redis.io/commands/publish
  675. * @example $redis->publish('chan-1', 'hello, world!'); // send message.
  676. */
  677. public function publish($channel, $message)
  678. {
  679. }
  680. /**
  681. * A command allowing you to get information on the Redis pub/sub system
  682. *
  683. * @param string $keyword String, which can be: "channels", "numsub", or "numpat"
  684. * @param string|array $argument Optional, variant.
  685. * For the "channels" subcommand, you can pass a string pattern.
  686. * For "numsub" an array of channel names
  687. *
  688. * @return array|int Either an integer or an array.
  689. * - channels Returns an array where the members are the matching channels.
  690. * - numsub Returns a key/value array where the keys are channel names and
  691. * values are their counts.
  692. * - numpat Integer return containing the number active pattern subscriptions
  693. *
  694. * @link https://redis.io/commands/pubsub
  695. * @example
  696. * <pre>
  697. * $redis->pubsub('channels'); // All channels
  698. * $redis->pubsub('channels', '*pattern*'); // Just channels matching your pattern
  699. * $redis->pubsub('numsub', array('chan1', 'chan2')); // Get subscriber counts for 'chan1' and 'chan2'
  700. * $redis->pubsub('numpat'); // Get the number of pattern subscribers
  701. * </pre>
  702. */
  703. public function pubsub($keyword, $argument)
  704. {
  705. }
  706. /**
  707. * Stop listening for messages posted to the given channels.
  708. *
  709. * @param array $channels an array of channels to usubscribe
  710. *
  711. * @link https://redis.io/commands/unsubscribe
  712. */
  713. public function unsubscribe($channels = null)
  714. {
  715. }
  716. /**
  717. * Stop listening for messages posted to the given channels.
  718. *
  719. * @param array $patterns an array of glob-style patterns to unsubscribe
  720. *
  721. * @link https://redis.io/commands/punsubscribe
  722. */
  723. public function punsubscribe($patterns = null)
  724. {
  725. }
  726. /**
  727. * Verify if the specified key/keys exists
  728. *
  729. * This function took a single argument and returned TRUE or FALSE in phpredis versions < 4.0.0.
  730. *
  731. * @since >= 4.0 Returned int, if < 4.0 returned bool
  732. *
  733. * @param string|string[] $key
  734. *
  735. * @return int|bool The number of keys tested that do exist
  736. *
  737. * @link https://redis.io/commands/exists
  738. * @link https://github.com/phpredis/phpredis#exists
  739. * @example
  740. * <pre>
  741. * $redis->exists('key'); // 1
  742. * $redis->exists('NonExistingKey'); // 0
  743. *
  744. * $redis->mset(['foo' => 'foo', 'bar' => 'bar', 'baz' => 'baz']);
  745. * $redis->exists(['foo', 'bar', 'baz]); // 3
  746. * $redis->exists('foo', 'bar', 'baz'); // 3
  747. * </pre>
  748. */
  749. public function exists($key)
  750. {
  751. }
  752. /**
  753. * Increment the number stored at key by one.
  754. *
  755. * @param string $key
  756. *
  757. * @return int the new value
  758. *
  759. * @link https://redis.io/commands/incr
  760. * @example
  761. * <pre>
  762. * $redis->incr('key1'); // key1 didn't exists, set to 0 before the increment and now has the value 1
  763. * $redis->incr('key1'); // 2
  764. * $redis->incr('key1'); // 3
  765. * $redis->incr('key1'); // 4
  766. * </pre>
  767. */
  768. public function incr($key)
  769. {
  770. }
  771. /**
  772. * Increment the float value of a key by the given amount
  773. *
  774. * @param string $key
  775. * @param float $increment
  776. *
  777. * @return float
  778. *
  779. * @link https://redis.io/commands/incrbyfloat
  780. * @example
  781. * <pre>
  782. * $redis->set('x', 3);
  783. * $redis->incrByFloat('x', 1.5); // float(4.5)
  784. * $redis->get('x'); // float(4.5)
  785. * </pre>
  786. */
  787. public function incrByFloat($key, $increment)
  788. {
  789. }
  790. /**
  791. * Increment the number stored at key by one.
  792. * If the second argument is filled, it will be used as the integer value of the increment.
  793. *
  794. * @param string $key key
  795. * @param int $value value that will be added to key (only for incrBy)
  796. *
  797. * @return int the new value
  798. *
  799. * @link https://redis.io/commands/incrby
  800. * @example
  801. * <pre>
  802. * $redis->incr('key1'); // key1 didn't exists, set to 0 before the increment and now has the value 1
  803. * $redis->incr('key1'); // 2
  804. * $redis->incr('key1'); // 3
  805. * $redis->incr('key1'); // 4
  806. * $redis->incrBy('key1', 10); // 14
  807. * </pre>
  808. */
  809. public function incrBy($key, $value)
  810. {
  811. }
  812. /**
  813. * Decrement the number stored at key by one.
  814. *
  815. * @param string $key
  816. *
  817. * @return int the new value
  818. *
  819. * @link https://redis.io/commands/decr
  820. * @example
  821. * <pre>
  822. * $redis->decr('key1'); // key1 didn't exists, set to 0 before the increment and now has the value -1
  823. * $redis->decr('key1'); // -2
  824. * $redis->decr('key1'); // -3
  825. * </pre>
  826. */
  827. public function decr($key)
  828. {
  829. }
  830. /**
  831. * Decrement the number stored at key by one.
  832. * If the second argument is filled, it will be used as the integer value of the decrement.
  833. *
  834. * @param string $key
  835. * @param int $value that will be substracted to key (only for decrBy)
  836. *
  837. * @return int the new value
  838. *
  839. * @link https://redis.io/commands/decrby
  840. * @example
  841. * <pre>
  842. * $redis->decr('key1'); // key1 didn't exists, set to 0 before the increment and now has the value -1
  843. * $redis->decr('key1'); // -2
  844. * $redis->decr('key1'); // -3
  845. * $redis->decrBy('key1', 10); // -13
  846. * </pre>
  847. */
  848. public function decrBy($key, $value)
  849. {
  850. }
  851. /**
  852. * Adds the string values to the head (left) of the list.
  853. * Creates the list if the key didn't exist.
  854. * If the key exists and is not a list, FALSE is returned.
  855. *
  856. * @param string $key
  857. * @param string|mixed $value1... Variadic list of values to push in key, if dont used serialized, used string
  858. *
  859. * @return int|bool The new length of the list in case of success, FALSE in case of Failure
  860. *
  861. * @link https://redis.io/commands/lpush
  862. * @example
  863. * <pre>
  864. * $redis->lPush('l', 'v1', 'v2', 'v3', 'v4') // int(4)
  865. * var_dump( $redis->lRange('l', 0, -1) );
  866. * // Output:
  867. * // array(4) {
  868. * // [0]=> string(2) "v4"
  869. * // [1]=> string(2) "v3"
  870. * // [2]=> string(2) "v2"
  871. * // [3]=> string(2) "v1"
  872. * // }
  873. * </pre>
  874. */
  875. public function lPush($key, ...$value1)
  876. {
  877. }
  878. /**
  879. * Adds the string values to the tail (right) of the list.
  880. * Creates the list if the key didn't exist.
  881. * If the key exists and is not a list, FALSE is returned.
  882. *
  883. * @param string $key
  884. * @param string|mixed $value1... Variadic list of values to push in key, if dont used serialized, used string
  885. *
  886. * @return int|bool The new length of the list in case of success, FALSE in case of Failure
  887. *
  888. * @link https://redis.io/commands/rpush
  889. * @example
  890. * <pre>
  891. * $redis->rPush('l', 'v1', 'v2', 'v3', 'v4'); // int(4)
  892. * var_dump( $redis->lRange('l', 0, -1) );
  893. * // Output:
  894. * // array(4) {
  895. * // [0]=> string(2) "v1"
  896. * // [1]=> string(2) "v2"
  897. * // [2]=> string(2) "v3"
  898. * // [3]=> string(2) "v4"
  899. * // }
  900. * </pre>
  901. */
  902. public function rPush($key, ...$value1)
  903. {
  904. }
  905. /**
  906. * Adds the string value to the head (left) of the list if the list exists.
  907. *
  908. * @param string $key
  909. * @param string|mixed $value String, value to push in key
  910. *
  911. * @return int|bool The new length of the list in case of success, FALSE in case of Failure.
  912. *
  913. * @link https://redis.io/commands/lpushx
  914. * @example
  915. * <pre>
  916. * $redis->del('key1');
  917. * $redis->lPushx('key1', 'A'); // returns 0
  918. * $redis->lPush('key1', 'A'); // returns 1
  919. * $redis->lPushx('key1', 'B'); // returns 2
  920. * $redis->lPushx('key1', 'C'); // returns 3
  921. * // key1 now points to the following list: [ 'A', 'B', 'C' ]
  922. * </pre>
  923. */
  924. public function lPushx($key, $value)
  925. {
  926. }
  927. /**
  928. * Adds the string value to the tail (right) of the list if the ist exists. FALSE in case of Failure.
  929. *
  930. * @param string $key
  931. * @param string|mixed $value String, value to push in key
  932. *
  933. * @return int|bool The new length of the list in case of success, FALSE in case of Failure.
  934. *
  935. * @link https://redis.io/commands/rpushx
  936. * @example
  937. * <pre>
  938. * $redis->del('key1');
  939. * $redis->rPushx('key1', 'A'); // returns 0
  940. * $redis->rPush('key1', 'A'); // returns 1
  941. * $redis->rPushx('key1', 'B'); // returns 2
  942. * $redis->rPushx('key1', 'C'); // returns 3
  943. * // key1 now points to the following list: [ 'A', 'B', 'C' ]
  944. * </pre>
  945. */
  946. public function rPushx($key, $value)
  947. {
  948. }
  949. /**
  950. * Returns and removes the first element of the list.
  951. *
  952. * @param string $key
  953. *
  954. * @return mixed|bool if command executed successfully BOOL FALSE in case of failure (empty list)
  955. *
  956. * @link https://redis.io/commands/lpop
  957. * @example
  958. * <pre>
  959. * $redis->rPush('key1', 'A');
  960. * $redis->rPush('key1', 'B');
  961. * $redis->rPush('key1', 'C'); // key1 => [ 'A', 'B', 'C' ]
  962. * $redis->lPop('key1'); // key1 => [ 'B', 'C' ]
  963. * </pre>
  964. */
  965. public function lPop($key)
  966. {
  967. }
  968. /**
  969. * Returns and removes the last element of the list.
  970. *
  971. * @param string $key
  972. *
  973. * @return mixed|bool if command executed successfully BOOL FALSE in case of failure (empty list)
  974. *
  975. * @link https://redis.io/commands/rpop
  976. * @example
  977. * <pre>
  978. * $redis->rPush('key1', 'A');
  979. * $redis->rPush('key1', 'B');
  980. * $redis->rPush('key1', 'C'); // key1 => [ 'A', 'B', 'C' ]
  981. * $redis->rPop('key1'); // key1 => [ 'A', 'B' ]
  982. * </pre>
  983. */
  984. public function rPop($key)
  985. {
  986. }
  987. /**
  988. * Is a blocking lPop primitive. If at least one of the lists contains at least one element,
  989. * the element will be popped from the head of the list and returned to the caller.
  990. * Il all the list identified by the keys passed in arguments are empty, blPop will block
  991. * during the specified timeout until an element is pushed to one of those lists. This element will be popped.
  992. *
  993. * @param string|string[] $keys String array containing the keys of the lists OR variadic list of strings
  994. * @param int $timeout Timeout is always the required final parameter
  995. *
  996. * @return array ['listName', 'element']
  997. *
  998. * @link https://redis.io/commands/blpop
  999. * @example
  1000. * <pre>
  1001. * // Non blocking feature
  1002. * $redis->lPush('key1', 'A');
  1003. * $redis->del('key2');
  1004. *
  1005. * $redis->blPop('key1', 'key2', 10); // array('key1', 'A')
  1006. * // OR
  1007. * $redis->blPop(['key1', 'key2'], 10); // array('key1', 'A')
  1008. *
  1009. * $redis->brPop('key1', 'key2', 10); // array('key1', 'A')
  1010. * // OR
  1011. * $redis->brPop(['key1', 'key2'], 10); // array('key1', 'A')
  1012. *
  1013. * // Blocking feature
  1014. *
  1015. * // process 1
  1016. * $redis->del('key1');
  1017. * $redis->blPop('key1', 10);
  1018. * // blocking for 10 seconds
  1019. *
  1020. * // process 2
  1021. * $redis->lPush('key1', 'A');
  1022. *
  1023. * // process 1
  1024. * // array('key1', 'A') is returned
  1025. * </pre>
  1026. */
  1027. public function blPop($keys, $timeout)
  1028. {
  1029. }
  1030. /**
  1031. * Is a blocking rPop primitive. If at least one of the lists contains at least one element,
  1032. * the element will be popped from the head of the list and returned to the caller.
  1033. * Il all the list identified by the keys passed in arguments are empty, brPop will
  1034. * block during the specified timeout until an element is pushed to one of those lists. T
  1035. * his element will be popped.
  1036. *
  1037. * @param string|string[] $keys String array containing the keys of the lists OR variadic list of strings
  1038. * @param int $timeout Timeout is always the required final parameter
  1039. *
  1040. * @return array ['listName', 'element']
  1041. *
  1042. * @link https://redis.io/commands/brpop
  1043. * @example
  1044. * <pre>
  1045. * // Non blocking feature
  1046. * $redis->lPush('key1', 'A');
  1047. * $redis->del('key2');
  1048. *
  1049. * $redis->blPop('key1', 'key2', 10); // array('key1', 'A')
  1050. * // OR
  1051. * $redis->blPop(array('key1', 'key2'), 10); // array('key1', 'A')
  1052. *
  1053. * $redis->brPop('key1', 'key2', 10); // array('key1', 'A')
  1054. * // OR
  1055. * $redis->brPop(array('key1', 'key2'), 10); // array('key1', 'A')
  1056. *
  1057. * // Blocking feature
  1058. *
  1059. * // process 1
  1060. * $redis->del('key1');
  1061. * $redis->blPop('key1', 10);
  1062. * // blocking for 10 seconds
  1063. *
  1064. * // process 2
  1065. * $redis->lPush('key1', 'A');
  1066. *
  1067. * // process 1
  1068. * // array('key1', 'A') is returned
  1069. * </pre>
  1070. */
  1071. public function brPop(array $keys, $timeout)
  1072. {
  1073. }
  1074. /**
  1075. * Returns the size of a list identified by Key. If the list didn't exist or is empty,
  1076. * the command returns 0. If the data type identified by Key is not a list, the command return FALSE.
  1077. *
  1078. * @param string $key
  1079. *
  1080. * @return int|bool The size of the list identified by Key exists.
  1081. * bool FALSE if the data type identified by Key is not list
  1082. *
  1083. * @link https://redis.io/commands/llen
  1084. * @example
  1085. * <pre>
  1086. * $redis->rPush('key1', 'A');
  1087. * $redis->rPush('key1', 'B');
  1088. * $redis->rPush('key1', 'C'); // key1 => [ 'A', 'B', 'C' ]
  1089. * $redis->lLen('key1'); // 3
  1090. * $redis->rPop('key1');
  1091. * $redis->lLen('key1'); // 2
  1092. * </pre>
  1093. */
  1094. public function lLen($key)
  1095. {
  1096. }
  1097. /**
  1098. * @see lLen()
  1099. * @link https://redis.io/commands/llen
  1100. * @deprecated use Redis::lLen()
  1101. *
  1102. * @param string $key
  1103. *
  1104. * @return int The size of the list identified by Key exists
  1105. */
  1106. public function lSize($key)
  1107. {
  1108. }
  1109. /**
  1110. * Return the specified element of the list stored at the specified key.
  1111. * 0 the first element, 1 the second ... -1 the last element, -2 the penultimate ...
  1112. * Return FALSE in case of a bad index or a key that doesn't point to a list.
  1113. *
  1114. * @param string $key
  1115. * @param int $index
  1116. *
  1117. * @return mixed|bool the element at this index
  1118. *
  1119. * Bool FALSE if the key identifies a non-string data type, or no value corresponds to this index in the list Key.
  1120. *
  1121. * @link https://redis.io/commands/lindex
  1122. * @example
  1123. * <pre>
  1124. * $redis->rPush('key1', 'A');
  1125. * $redis->rPush('key1', 'B');
  1126. * $redis->rPush('key1', 'C'); // key1 => [ 'A', 'B', 'C' ]
  1127. * $redis->lIndex('key1', 0); // 'A'
  1128. * $redis->lIndex('key1', -1); // 'C'
  1129. * $redis->lIndex('key1', 10); // `FALSE`
  1130. * </pre>
  1131. */
  1132. public function lIndex($key, $index)
  1133. {
  1134. }
  1135. /**
  1136. * @see lIndex()
  1137. * @link https://redis.io/commands/lindex
  1138. * @deprecated use Redis::lIndex()
  1139. *
  1140. * @param string $key
  1141. * @param int $index
  1142. * @return mixed|bool the element at this index
  1143. */
  1144. public function lGet($key, $index)
  1145. {
  1146. }
  1147. /**
  1148. * Set the list at index with the new value.
  1149. *
  1150. * @param string $key
  1151. * @param int $index
  1152. * @param string $value
  1153. *
  1154. * @return bool TRUE if the new value is setted.
  1155. * FALSE if the index is out of range, or data type identified by key is not a list.
  1156. *
  1157. * @link https://redis.io/commands/lset
  1158. * @example
  1159. * <pre>
  1160. * $redis->rPush('key1', 'A');
  1161. * $redis->rPush('key1', 'B');
  1162. * $redis->rPush('key1', 'C'); // key1 => [ 'A', 'B', 'C' ]
  1163. * $redis->lIndex('key1', 0); // 'A'
  1164. * $redis->lSet('key1', 0, 'X');
  1165. * $redis->lIndex('key1', 0); // 'X'
  1166. * </pre>
  1167. */
  1168. public function lSet($key, $index, $value)
  1169. {
  1170. }
  1171. /**
  1172. * Returns the specified elements of the list stored at the specified key in
  1173. * the range [start, end]. start and stop are interpretated as indices: 0 the first element,
  1174. * 1 the second ... -1 the last element, -2 the penultimate ...
  1175. *
  1176. * @param string $key
  1177. * @param int $start
  1178. * @param int $end
  1179. *
  1180. * @return array containing the values in specified range.
  1181. *
  1182. * @link https://redis.io/commands/lrange
  1183. * @example
  1184. * <pre>
  1185. * $redis->rPush('key1', 'A');
  1186. * $redis->rPush('key1', 'B');
  1187. * $redis->rPush('key1', 'C');
  1188. * $redis->lRange('key1', 0, -1); // array('A', 'B', 'C')
  1189. * </pre>
  1190. */
  1191. public function lRange($key, $start, $end)
  1192. {
  1193. }
  1194. /**
  1195. * @see lRange()
  1196. * @link https://redis.io/commands/lrange
  1197. * @deprecated use Redis::lRange()
  1198. *
  1199. * @param string $key
  1200. * @param int $start
  1201. * @param int $end
  1202. * @return array
  1203. */
  1204. public function lGetRange($key, $start, $end)
  1205. {
  1206. }
  1207. /**
  1208. * Trims an existing list so that it will contain only a specified range of elements.
  1209. *
  1210. * @param string $key
  1211. * @param int $start
  1212. * @param int $stop
  1213. *
  1214. * @return array|bool Bool return FALSE if the key identify a non-list value
  1215. *
  1216. * @link https://redis.io/commands/ltrim
  1217. * @example
  1218. * <pre>
  1219. * $redis->rPush('key1', 'A');
  1220. * $redis->rPush('key1', 'B');
  1221. * $redis->rPush('key1', 'C');
  1222. * $redis->lRange('key1', 0, -1); // array('A', 'B', 'C')
  1223. * $redis->lTrim('key1', 0, 1);
  1224. * $redis->lRange('key1', 0, -1); // array('A', 'B')
  1225. * </pre>
  1226. */
  1227. public function lTrim($key, $start, $stop)
  1228. {
  1229. }
  1230. /**
  1231. * @see lTrim()
  1232. * @link https://redis.io/commands/ltrim
  1233. * @deprecated use Redis::lTrim()
  1234. *
  1235. * @param string $key
  1236. * @param int $start
  1237. * @param int $stop
  1238. */
  1239. public function listTrim($key, $start, $stop)
  1240. {
  1241. }
  1242. /**
  1243. * Removes the first count occurences of the value element from the list.
  1244. * If count is zero, all the matching elements are removed. If count is negative,
  1245. * elements are removed from tail to head.
  1246. *
  1247. * @param string $key
  1248. * @param string $value
  1249. * @param int $count
  1250. *
  1251. * @return int|bool the number of elements to remove
  1252. * bool FALSE if the value identified by key is not a list.
  1253. *
  1254. * @link https://redis.io/commands/lrem
  1255. * @example
  1256. * <pre>
  1257. * $redis->lPush('key1', 'A');
  1258. * $redis->lPush('key1', 'B');
  1259. * $redis->lPush('key1', 'C');
  1260. * $redis->lPush('key1', 'A');
  1261. * $redis->lPush('key1', 'A');
  1262. *
  1263. * $redis->lRange('key1', 0, -1); // array('A', 'A', 'C', 'B', 'A')
  1264. * $redis->lRem('key1', 'A', 2); // 2
  1265. * $redis->lRange('key1', 0, -1); // array('C', 'B', 'A')
  1266. * </pre>
  1267. */
  1268. public function lRem($key, $value, $count)
  1269. {
  1270. }
  1271. /**
  1272. * @see lRem
  1273. * @link https://redis.io/commands/lremove
  1274. * @deprecated use Redis::lRem()
  1275. *
  1276. * @param string $key
  1277. * @param string $value
  1278. * @param int $count
  1279. */
  1280. public function lRemove($key, $value, $count)
  1281. {
  1282. }
  1283. /**
  1284. * Insert value in the list before or after the pivot value. the parameter options
  1285. * specify the position of the insert (before or after). If the list didn't exists,
  1286. * or the pivot didn't exists, the value is not inserted.
  1287. *
  1288. * @param string $key
  1289. * @param int $position Redis::BEFORE | Redis::AFTER
  1290. * @param string $pivot
  1291. * @param string|mixed $value
  1292. *
  1293. * @return int The number of the elements in the list, -1 if the pivot didn't exists.
  1294. *
  1295. * @link https://redis.io/commands/linsert
  1296. * @example
  1297. * <pre>
  1298. * $redis->del('key1');
  1299. * $redis->lInsert('key1', Redis::AFTER, 'A', 'X'); // 0
  1300. *
  1301. * $redis->lPush('key1', 'A');
  1302. * $redis->lPush('key1', 'B');
  1303. * $redis->lPush('key1', 'C');
  1304. *
  1305. * $redis->lInsert('key1', Redis::BEFORE, 'C', 'X'); // 4
  1306. * $redis->lRange('key1', 0, -1); // array('A', 'B', 'X', 'C')
  1307. *
  1308. * $redis->lInsert('key1', Redis::AFTER, 'C', 'Y'); // 5
  1309. * $redis->lRange('key1', 0, -1); // array('A', 'B', 'X', 'C', 'Y')
  1310. *
  1311. * $redis->lInsert('key1', Redis::AFTER, 'W', 'value'); // -1
  1312. * </pre>
  1313. */
  1314. public function lInsert($key, $position, $pivot, $value)
  1315. {
  1316. }
  1317. /**
  1318. * Adds a values to the set value stored at key.
  1319. *
  1320. * @param string $key Required key
  1321. * @param string|mixed ...$value1 Variadic list of values
  1322. *
  1323. * @return int|bool The number of elements added to the set.
  1324. * If this value is already in the set, FALSE is returned
  1325. *
  1326. * @link https://redis.io/commands/sadd
  1327. * @example
  1328. * <pre>
  1329. * $redis->sAdd('k', 'v1'); // int(1)
  1330. * $redis->sAdd('k', 'v1', 'v2', 'v3'); // int(2)
  1331. * </pre>
  1332. */
  1333. public function sAdd($key, ...$value1)
  1334. {
  1335. }
  1336. /**
  1337. * Removes the specified members from the set value stored at key.
  1338. *
  1339. * @param string $key
  1340. * @param string|mixed ...$member1 Variadic list of members
  1341. *
  1342. * @return int The number of elements removed from the set
  1343. *
  1344. * @link https://redis.io/commands/srem
  1345. * @example
  1346. * <pre>
  1347. * var_dump( $redis->sAdd('k', 'v1', 'v2', 'v3') ); // int(3)
  1348. * var_dump( $redis->sRem('k', 'v2', 'v3') ); // int(2)
  1349. * var_dump( $redis->sMembers('k') );
  1350. * //// Output:
  1351. * // array(1) {
  1352. * // [0]=> string(2) "v1"
  1353. * // }
  1354. * </pre>
  1355. */
  1356. public function sRem($key, ...$member1)
  1357. {
  1358. }
  1359. /**
  1360. * @see sRem()
  1361. * @link https://redis.io/commands/srem
  1362. * @deprecated use Redis::sRem()
  1363. *
  1364. * @param string $key
  1365. * @param string|mixed ...$member1
  1366. */
  1367. public function sRemove($key, ...$member1)
  1368. {
  1369. }
  1370. /**
  1371. * Moves the specified member from the set at srcKey to the set at dstKey.
  1372. *
  1373. * @param string $srcKey
  1374. * @param string $dstKey
  1375. * @param string|mixed $member
  1376. *
  1377. * @return bool If the operation is successful, return TRUE.
  1378. * If the srcKey and/or dstKey didn't exist, and/or the member didn't exist in srcKey, FALSE is returned.
  1379. *
  1380. * @link https://redis.io/commands/smove
  1381. * @example
  1382. * <pre>
  1383. * $redis->sAdd('key1' , 'set11');
  1384. * $redis->sAdd('key1' , 'set12');
  1385. * $redis->sAdd('key1' , 'set13'); // 'key1' => {'set11', 'set12', 'set13'}
  1386. * $redis->sAdd('key2' , 'set21');
  1387. * $redis->sAdd('key2' , 'set22'); // 'key2' => {'set21', 'set22'}
  1388. * $redis->sMove('key1', 'key2', 'set13'); // 'key1' => {'set11', 'set12'}
  1389. * // 'key2' => {'set21', 'set22', 'set13'}
  1390. * </pre>
  1391. */
  1392. public function sMove($srcKey, $dstKey, $member)
  1393. {
  1394. }
  1395. /**
  1396. * Checks if value is a member of the set stored at the key key.
  1397. *
  1398. * @param string $key
  1399. * @param string|mixed $value
  1400. *
  1401. * @return bool TRUE if value is a member of the set at key key, FALSE otherwise
  1402. *
  1403. * @link https://redis.io/commands/sismember
  1404. * @example
  1405. * <pre>
  1406. * $redis->sAdd('key1' , 'set1');
  1407. * $redis->sAdd('key1' , 'set2');
  1408. * $redis->sAdd('key1' , 'set3'); // 'key1' => {'set1', 'set2', 'set3'}
  1409. *
  1410. * $redis->sIsMember('key1', 'set1'); // TRUE
  1411. * $redis->sIsMember('key1', 'setX'); // FALSE
  1412. * </pre>
  1413. */
  1414. public function sIsMember($key, $value)
  1415. {
  1416. }
  1417. /**
  1418. * @see sIsMember()
  1419. * @link https://redis.io/commands/sismember
  1420. * @deprecated use Redis::sIsMember()
  1421. *
  1422. * @param string $key
  1423. * @param string|mixed $value
  1424. */
  1425. public function sContains($key, $value)
  1426. {
  1427. }
  1428. /**
  1429. * Returns the cardinality of the set identified by key.
  1430. *
  1431. * @param string $key
  1432. *
  1433. * @return int the cardinality of the set identified by key, 0 if the set doesn't exist.
  1434. *
  1435. * @link https://redis.io/commands/scard
  1436. * @example
  1437. * <pre>
  1438. * $redis->sAdd('key1' , 'set1');
  1439. * $redis->sAdd('key1' , 'set2');
  1440. * $redis->sAdd('key1' , 'set3'); // 'key1' => {'set1', 'set2', 'set3'}
  1441. * $redis->sCard('key1'); // 3
  1442. * $redis->sCard('keyX'); // 0
  1443. * </pre>
  1444. */
  1445. public function sCard($key)
  1446. {
  1447. }
  1448. /**
  1449. * Removes and returns a random element from the set value at Key.
  1450. *
  1451. * @param string $key
  1452. *
  1453. * @return string|mixed|bool "popped" value
  1454. * bool FALSE if set identified by key is empty or doesn't exist.
  1455. *
  1456. * @link https://redis.io/commands/spop
  1457. * @example
  1458. * <pre>
  1459. * $redis->sAdd('key1' , 'set1');
  1460. * $redis->sAdd('key1' , 'set2');
  1461. * $redis->sAdd('key1' , 'set3'); // 'key1' => {'set3', 'set1', 'set2'}
  1462. * $redis->sPop('key1'); // 'set1', 'key1' => {'set3', 'set2'}
  1463. * $redis->sPop('key1'); // 'set3', 'key1' => {'set2'}
  1464. * </pre>
  1465. */
  1466. public function sPop($key)
  1467. {
  1468. }
  1469. /**
  1470. * Returns a random element(s) from the set value at Key, without removing it.
  1471. *
  1472. * @param string $key
  1473. * @param int $count [optional]
  1474. *
  1475. * @return string|mixed|array|bool value(s) from the set
  1476. * bool FALSE if set identified by key is empty or doesn't exist and count argument isn't passed.
  1477. *
  1478. * @link https://redis.io/commands/srandmember
  1479. * @example
  1480. * <pre>
  1481. * $redis->sAdd('key1' , 'one');
  1482. * $redis->sAdd('key1' , 'two');
  1483. * $redis->sAdd('key1' , 'three'); // 'key1' => {'one', 'two', 'three'}
  1484. *
  1485. * var_dump( $redis->sRandMember('key1') ); // 'key1' => {'one', 'two', 'three'}
  1486. *
  1487. * // string(5) "three"
  1488. *
  1489. * var_dump( $redis->sRandMember('key1', 2) ); // 'key1' => {'one', 'two', 'three'}
  1490. *
  1491. * // array(2) {
  1492. * // [0]=> string(2) "one"
  1493. * // [1]=> string(2) "three"
  1494. * // }
  1495. * </pre>
  1496. */
  1497. public function sRandMember($key, $count = 1)
  1498. {
  1499. }
  1500. /**
  1501. * Returns the members of a set resulting from the intersection of all the sets
  1502. * held at the specified keys. If just a single key is specified, then this command
  1503. * produces the members of this set. If one of the keys is missing, FALSE is returned.
  1504. *
  1505. * @param string $key1 keys identifying the different sets on which we will apply the intersection.
  1506. * @param string ...$otherKeys variadic list of keys
  1507. *
  1508. * @return array contain the result of the intersection between those keys
  1509. * If the intersection between the different sets is empty, the return value will be empty array.
  1510. *
  1511. * @link https://redis.io/commands/sinter
  1512. * @example
  1513. * <pre>
  1514. * $redis->sAdd('key1', 'val1');
  1515. * $redis->sAdd('key1', 'val2');
  1516. * $redis->sAdd('key1', 'val3');
  1517. * $redis->sAdd('key1', 'val4');
  1518. *
  1519. * $redis->sAdd('key2', 'val3');
  1520. * $redis->sAdd('key2', 'val4');
  1521. *
  1522. * $redis->sAdd('key3', 'val3');
  1523. * $redis->sAdd('key3', 'val4');
  1524. *
  1525. * var_dump($redis->sInter('key1', 'key2', 'key3'));
  1526. *
  1527. * //array(2) {
  1528. * // [0]=>
  1529. * // string(4) "val4"
  1530. * // [1]=>
  1531. * // string(4) "val3"
  1532. * //}
  1533. * </pre>
  1534. */
  1535. public function sInter($key1, ...$otherKeys)
  1536. {
  1537. }
  1538. /**
  1539. * Performs a sInter command and stores the result in a new set.
  1540. *
  1541. * @param string $dstKey the key to store the diff into.
  1542. * @param string $key1 keys identifying the different sets on which we will apply the intersection.
  1543. * @param string ...$otherKeys variadic list of keys
  1544. *
  1545. * @return int|bool The cardinality of the resulting set, or FALSE in case of a missing key
  1546. *
  1547. * @link https://redis.io/commands/sinterstore
  1548. * @example
  1549. * <pre>
  1550. * $redis->sAdd('key1', 'val1');
  1551. * $redis->sAdd('key1', 'val2');
  1552. * $redis->sAdd('key1', 'val3');
  1553. * $redis->sAdd('key1', 'val4');
  1554. *
  1555. * $redis->sAdd('key2', 'val3');
  1556. * $redis->sAdd('key2', 'val4');
  1557. *
  1558. * $redis->sAdd('key3', 'val3');
  1559. * $redis->sAdd('key3', 'val4');
  1560. *
  1561. * var_dump($redis->sInterStore('output', 'key1', 'key2', 'key3'));
  1562. * var_dump($redis->sMembers('output'));
  1563. *
  1564. * //int(2)
  1565. * //
  1566. * //array(2) {
  1567. * // [0]=>
  1568. * // string(4) "val4"
  1569. * // [1]=>
  1570. * // string(4) "val3"
  1571. * //}
  1572. * </pre>
  1573. */
  1574. public function sInterStore($dstKey, $key1, ...$otherKeys)
  1575. {
  1576. }
  1577. /**
  1578. * Performs the union between N sets and returns it.
  1579. *
  1580. * @param string $key1 first key for union
  1581. * @param string ...$otherKeys variadic list of keys corresponding to sets in redis
  1582. *
  1583. * @return array string[] The union of all these sets
  1584. *
  1585. * @link https://redis.io/commands/sunionstore
  1586. * @example
  1587. * <pre>
  1588. * $redis->sAdd('s0', '1');
  1589. * $redis->sAdd('s0', '2');
  1590. * $redis->sAdd('s1', '3');
  1591. * $redis->sAdd('s1', '1');
  1592. * $redis->sAdd('s2', '3');
  1593. * $redis->sAdd('s2', '4');
  1594. *
  1595. * var_dump($redis->sUnion('s0', 's1', 's2'));
  1596. *
  1597. * array(4) {
  1598. * // [0]=>
  1599. * // string(1) "3"
  1600. * // [1]=>
  1601. * // string(1) "4"
  1602. * // [2]=>
  1603. * // string(1) "1"
  1604. * // [3]=>
  1605. * // string(1) "2"
  1606. * //}
  1607. * </pre>
  1608. */
  1609. public function sUnion($key1, ...$otherKeys)
  1610. {
  1611. }
  1612. /**
  1613. * Performs the same action as sUnion, but stores the result in the first key
  1614. *
  1615. * @param string $dstKey the key to store the diff into.
  1616. * @param string $key1 first key for union
  1617. * @param string ...$otherKeys variadic list of keys corresponding to sets in redis
  1618. *
  1619. * @return int Any number of keys corresponding to sets in redis
  1620. *
  1621. * @link https://redis.io/commands/sunionstore
  1622. * @example
  1623. * <pre>
  1624. * $redis->del('s0', 's1', 's2');
  1625. *
  1626. * $redis->sAdd('s0', '1');
  1627. * $redis->sAdd('s0', '2');
  1628. * $redis->sAdd('s1', '3');
  1629. * $redis->sAdd('s1', '1');
  1630. * $redis->sAdd('s2', '3');
  1631. * $redis->sAdd('s2', '4');
  1632. *
  1633. * var_dump($redis->sUnionStore('dst', 's0', 's1', 's2'));
  1634. * var_dump($redis->sMembers('dst'));
  1635. *
  1636. * //int(4)
  1637. * //array(4) {
  1638. * // [0]=>
  1639. * // string(1) "3"
  1640. * // [1]=>
  1641. * // string(1) "4"
  1642. * // [2]=>
  1643. * // string(1) "1"
  1644. * // [3]=>
  1645. * // string(1) "2"
  1646. * //}
  1647. * </pre>
  1648. */
  1649. public function sUnionStore($dstKey, $key1, ...$otherKeys)
  1650. {
  1651. }
  1652. /**
  1653. * Performs the difference between N sets and returns it.
  1654. *
  1655. * @param string $key1 first key for diff
  1656. * @param string ...$otherKeys variadic list of keys corresponding to sets in redis
  1657. *
  1658. * @return array string[] The difference of the first set will all the others
  1659. *
  1660. * @link https://redis.io/commands/sdiff
  1661. * @example
  1662. * <pre>
  1663. * $redis->del('s0', 's1', 's2');
  1664. *
  1665. * $redis->sAdd('s0', '1');
  1666. * $redis->sAdd('s0', '2');
  1667. * $redis->sAdd('s0', '3');
  1668. * $redis->sAdd('s0', '4');
  1669. *
  1670. * $redis->sAdd('s1', '1');
  1671. * $redis->sAdd('s2', '3');
  1672. *
  1673. * var_dump($redis->sDiff('s0', 's1', 's2'));
  1674. *
  1675. * //array(2) {
  1676. * // [0]=>
  1677. * // string(1) "4"
  1678. * // [1]=>
  1679. * // string(1) "2"
  1680. * //}
  1681. * </pre>
  1682. */
  1683. public function sDiff($key1, ...$otherKeys)
  1684. {
  1685. }
  1686. /**
  1687. * Performs the same action as sDiff, but stores the result in the first key
  1688. *
  1689. * @param string $dstKey the key to store the diff into.
  1690. * @param string $key1 first key for diff
  1691. * @param string ...$otherKeys variadic list of keys corresponding to sets in redis
  1692. *
  1693. * @return int|bool The cardinality of the resulting set, or FALSE in case of a missing key
  1694. *
  1695. * @link https://redis.io/commands/sdiffstore
  1696. * @example
  1697. * <pre>
  1698. * $redis->del('s0', 's1', 's2');
  1699. *
  1700. * $redis->sAdd('s0', '1');
  1701. * $redis->sAdd('s0', '2');
  1702. * $redis->sAdd('s0', '3');
  1703. * $redis->sAdd('s0', '4');
  1704. *
  1705. * $redis->sAdd('s1', '1');
  1706. * $redis->sAdd('s2', '3');
  1707. *
  1708. * var_dump($redis->sDiffStore('dst', 's0', 's1', 's2'));
  1709. * var_dump($redis->sMembers('dst'));
  1710. *
  1711. * //int(2)
  1712. * //array(2) {
  1713. * // [0]=>
  1714. * // string(1) "4"
  1715. * // [1]=>
  1716. * // string(1) "2"
  1717. * //}
  1718. * </pre>
  1719. */
  1720. public function sDiffStore($dstKey, $key1, ...$otherKeys)
  1721. {
  1722. }
  1723. /**
  1724. * Returns the contents of a set.
  1725. *
  1726. * @param string $key
  1727. *
  1728. * @return array An array of elements, the contents of the set
  1729. *
  1730. * @link https://redis.io/commands/smembers
  1731. * @example
  1732. * <pre>
  1733. * $redis->del('s');
  1734. * $redis->sAdd('s', 'a');
  1735. * $redis->sAdd('s', 'b');
  1736. * $redis->sAdd('s', 'a');
  1737. * $redis->sAdd('s', 'c');
  1738. * var_dump($redis->sMembers('s'));
  1739. *
  1740. * //array(3) {
  1741. * // [0]=>
  1742. * // string(1) "c"
  1743. * // [1]=>
  1744. * // string(1) "a"
  1745. * // [2]=>
  1746. * // string(1) "b"
  1747. * //}
  1748. * // The order is random and corresponds to redis' own internal representation of the set structure.
  1749. * </pre>
  1750. */
  1751. public function sMembers($key)
  1752. {
  1753. }
  1754. /**
  1755. * @see sMembers()
  1756. * @link https://redis.io/commands/smembers
  1757. * @deprecated use Redis::sMembers()
  1758. *
  1759. * @param string $key
  1760. * @return array An array of elements, the contents of the set
  1761. */
  1762. public function sGetMembers($key)
  1763. {
  1764. }
  1765. /**
  1766. * Scan a set for members
  1767. *
  1768. * @param string $key The set to search.
  1769. * @param int $iterator LONG (reference) to the iterator as we go.
  1770. * @param string $pattern String, optional pattern to match against.
  1771. * @param int $count How many members to return at a time (Redis might return a different amount)
  1772. *
  1773. * @return array|bool PHPRedis will return an array of keys or FALSE when we're done iterating
  1774. *
  1775. * @link https://redis.io/commands/sscan
  1776. * @example
  1777. * <pre>
  1778. * $iterator = null;
  1779. * while ($members = $redis->sScan('set', $iterator)) {
  1780. * foreach ($members as $member) {
  1781. * echo $member . PHP_EOL;
  1782. * }
  1783. * }
  1784. * </pre>
  1785. */
  1786. public function sScan($key, &$iterator, $pattern = null, $count = 0)
  1787. {
  1788. }
  1789. /**
  1790. * Sets a value and returns the previous entry at that key.
  1791. *
  1792. * @param string $key
  1793. * @param string|mixed $value
  1794. *
  1795. * @return string|mixed A string (mixed, if used serializer), the previous value located at this key
  1796. *
  1797. * @link https://redis.io/commands/getset
  1798. * @example
  1799. * <pre>
  1800. * $redis->set('x', '42');
  1801. * $exValue = $redis->getSet('x', 'lol'); // return '42', replaces x by 'lol'
  1802. * $newValue = $redis->get('x')' // return 'lol'
  1803. * </pre>
  1804. */
  1805. public function getSet($key, $value)
  1806. {
  1807. }
  1808. /**
  1809. * Returns a random key
  1810. *
  1811. * @return string an existing key in redis
  1812. *
  1813. * @link https://redis.io/commands/randomkey
  1814. * @example
  1815. * <pre>
  1816. * $key = $redis->randomKey();
  1817. * $surprise = $redis->get($key); // who knows what's in there.
  1818. * </pre>
  1819. */
  1820. public function randomKey()
  1821. {
  1822. }
  1823. /**
  1824. * Switches to a given database
  1825. *
  1826. * @param int $dbIndex
  1827. *
  1828. * @return bool TRUE in case of success, FALSE in case of failure
  1829. *
  1830. * @link https://redis.io/commands/select
  1831. * @example
  1832. * <pre>
  1833. * $redis->select(0); // switch to DB 0
  1834. * $redis->set('x', '42'); // write 42 to x
  1835. * $redis->move('x', 1); // move to DB 1
  1836. * $redis->select(1); // switch to DB 1
  1837. * $redis->get('x'); // will return 42
  1838. * </pre>
  1839. */
  1840. public function select($dbIndex)
  1841. {
  1842. }
  1843. /**
  1844. * Moves a key to a different database.
  1845. *
  1846. * @param string $key
  1847. * @param int $dbIndex
  1848. *
  1849. * @return bool TRUE in case of success, FALSE in case of failure
  1850. *
  1851. * @link https://redis.io/commands/move
  1852. * @example
  1853. * <pre>
  1854. * $redis->select(0); // switch to DB 0
  1855. * $redis->set('x', '42'); // write 42 to x
  1856. * $redis->move('x', 1); // move to DB 1
  1857. * $redis->select(1); // switch to DB 1
  1858. * $redis->get('x'); // will return 42
  1859. * </pre>
  1860. */
  1861. public function move($key, $dbIndex)
  1862. {
  1863. }
  1864. /**
  1865. * Renames a key
  1866. *
  1867. * @param string $srcKey
  1868. * @param string $dstKey
  1869. *
  1870. * @return bool TRUE in case of success, FALSE in case of failure
  1871. *
  1872. * @link https://redis.io/commands/rename
  1873. * @example
  1874. * <pre>
  1875. * $redis->set('x', '42');
  1876. * $redis->rename('x', 'y');
  1877. * $redis->get('y'); // → 42
  1878. * $redis->get('x'); // → `FALSE`
  1879. * </pre>
  1880. */
  1881. public function rename($srcKey, $dstKey)
  1882. {
  1883. }
  1884. /**
  1885. * @see rename()
  1886. * @link https://redis.io/commands/rename
  1887. * @deprecated use Redis::rename()
  1888. *
  1889. * @param string $srcKey
  1890. * @param string $dstKey
  1891. */
  1892. public function renameKey($srcKey, $dstKey)
  1893. {
  1894. }
  1895. /**
  1896. * Renames a key
  1897. *
  1898. * Same as rename, but will not replace a key if the destination already exists.
  1899. * This is the same behaviour as setNx.
  1900. *
  1901. * @param string $srcKey
  1902. * @param string $dstKey
  1903. *
  1904. * @return bool TRUE in case of success, FALSE in case of failure
  1905. *
  1906. * @link https://redis.io/commands/renamenx
  1907. * @example
  1908. * <pre>
  1909. * $redis->set('x', '42');
  1910. * $redis->rename('x', 'y');
  1911. * $redis->get('y'); // → 42
  1912. * $redis->get('x'); // → `FALSE`
  1913. * </pre>
  1914. */
  1915. public function renameNx($srcKey, $dstKey)
  1916. {
  1917. }
  1918. /**
  1919. * Sets an expiration date (a timeout) on an item
  1920. *
  1921. * @param string $key The key that will disappear
  1922. * @param int $ttl The key's remaining Time To Live, in seconds
  1923. *
  1924. * @return bool TRUE in case of success, FALSE in case of failure
  1925. *
  1926. * @link https://redis.io/commands/expire
  1927. * @example
  1928. * <pre>
  1929. * $redis->set('x', '42');
  1930. * $redis->expire('x', 3); // x will disappear in 3 seconds.
  1931. * sleep(5); // wait 5 seconds
  1932. * $redis->get('x'); // will return `FALSE`, as 'x' has expired.
  1933. * </pre>
  1934. */
  1935. public function expire($key, $ttl)
  1936. {
  1937. }
  1938. /**
  1939. * Sets an expiration date (a timeout in milliseconds) on an item
  1940. *
  1941. * @param string $key The key that will disappear.
  1942. * @param int $ttl The key's remaining Time To Live, in milliseconds
  1943. *
  1944. * @return bool TRUE in case of success, FALSE in case of failure
  1945. *
  1946. * @link https://redis.io/commands/pexpire
  1947. * @example
  1948. * <pre>
  1949. * $redis->set('x', '42');
  1950. * $redis->pExpire('x', 11500); // x will disappear in 11500 milliseconds.
  1951. * $redis->ttl('x'); // 12
  1952. * $redis->pttl('x'); // 11500
  1953. * </pre>
  1954. */
  1955. public function pExpire($key, $ttl)
  1956. {
  1957. }
  1958. /**
  1959. * @see expire()
  1960. * @link https://redis.io/commands/expire
  1961. * @deprecated use Redis::expire()
  1962. *
  1963. * @param string $key
  1964. * @param int $ttl
  1965. * @return bool
  1966. */
  1967. public function setTimeout($key, $ttl)
  1968. {
  1969. }
  1970. /**
  1971. * Sets an expiration date (a timestamp) on an item.
  1972. *
  1973. * @param string $key The key that will disappear.
  1974. * @param int $timestamp Unix timestamp. The key's date of death, in seconds from Epoch time.
  1975. *
  1976. * @return bool TRUE in case of success, FALSE in case of failure
  1977. *
  1978. * @link https://redis.io/commands/expireat
  1979. * @example
  1980. * <pre>
  1981. * $redis->set('x', '42');
  1982. * $now = time(NULL); // current timestamp
  1983. * $redis->expireAt('x', $now + 3); // x will disappear in 3 seconds.
  1984. * sleep(5); // wait 5 seconds
  1985. * $redis->get('x'); // will return `FALSE`, as 'x' has expired.
  1986. * </pre>
  1987. */
  1988. public function expireAt($key, $timestamp)
  1989. {
  1990. }
  1991. /**
  1992. * Sets an expiration date (a timestamp) on an item. Requires a timestamp in milliseconds
  1993. *
  1994. * @param string $key The key that will disappear
  1995. * @param int $timestamp Unix timestamp. The key's date of death, in seconds from Epoch time
  1996. *
  1997. * @return bool TRUE in case of success, FALSE in case of failure
  1998. *
  1999. * @link https://redis.io/commands/pexpireat
  2000. * @example
  2001. * <pre>
  2002. * $redis->set('x', '42');
  2003. * $redis->pExpireAt('x', 1555555555005);
  2004. * echo $redis->ttl('x'); // 218270121
  2005. * echo $redis->pttl('x'); // 218270120575
  2006. * </pre>
  2007. */
  2008. public function pExpireAt($key, $timestamp)
  2009. {
  2010. }
  2011. /**
  2012. * Returns the keys that match a certain pattern.
  2013. *
  2014. * @param string $pattern pattern, using '*' as a wildcard
  2015. *
  2016. * @return array string[] The keys that match a certain pattern.
  2017. *
  2018. * @link https://redis.io/commands/keys
  2019. * @example
  2020. * <pre>
  2021. * $allKeys = $redis->keys('*'); // all keys will match this.
  2022. * $keyWithUserPrefix = $redis->keys('user*');
  2023. * </pre>
  2024. */
  2025. public function keys($pattern)
  2026. {
  2027. }
  2028. /**
  2029. * @see keys()
  2030. * @deprecated use Redis::keys()
  2031. *
  2032. * @param string $pattern
  2033. * @link https://redis.io/commands/keys
  2034. */
  2035. public function getKeys($pattern)
  2036. {
  2037. }
  2038. /**
  2039. * Returns the current database's size
  2040. *
  2041. * @return int DB size, in number of keys
  2042. *
  2043. * @link https://redis.io/commands/dbsize
  2044. * @example
  2045. * <pre>
  2046. * $count = $redis->dbSize();
  2047. * echo "Redis has $count keys\n";
  2048. * </pre>
  2049. */
  2050. public function dbSize()
  2051. {
  2052. }
  2053. /**
  2054. * Authenticate the connection using a password.
  2055. * Warning: The password is sent in plain-text over the network.
  2056. *
  2057. * @param string $password
  2058. *
  2059. * @return bool TRUE if the connection is authenticated, FALSE otherwise
  2060. *
  2061. * @link https://redis.io/commands/auth
  2062. * @example $redis->auth('foobared');
  2063. */
  2064. public function auth($password)
  2065. {
  2066. }
  2067. /**
  2068. * Starts the background rewrite of AOF (Append-Only File)
  2069. *
  2070. * @return bool TRUE in case of success, FALSE in case of failure
  2071. *
  2072. * @link https://redis.io/commands/bgrewriteaof
  2073. * @example $redis->bgrewriteaof();
  2074. */
  2075. public function bgrewriteaof()
  2076. {
  2077. }
  2078. /**
  2079. * Changes the slave status
  2080. * Either host and port, or no parameter to stop being a slave.
  2081. *
  2082. * @param string $host [optional]
  2083. * @param int $port [optional]
  2084. *
  2085. * @return bool TRUE in case of success, FALSE in case of failure
  2086. *
  2087. * @link https://redis.io/commands/slaveof
  2088. * @example
  2089. * <pre>
  2090. * $redis->slaveof('10.0.1.7', 6379);
  2091. * // ...
  2092. * $redis->slaveof();
  2093. * </pre>
  2094. */
  2095. public function slaveof($host = '127.0.0.1', $port = 6379)
  2096. {
  2097. }
  2098. /**
  2099. * Access the Redis slowLog
  2100. *
  2101. * @param string $operation This can be either GET, LEN, or RESET
  2102. * @param int|null $length If executing a SLOWLOG GET command, you can pass an optional length.
  2103. *
  2104. * @return mixed The return value of SLOWLOG will depend on which operation was performed.
  2105. * - SLOWLOG GET: Array of slowLog entries, as provided by Redis
  2106. * - SLOGLOG LEN: Integer, the length of the slowLog
  2107. * - SLOWLOG RESET: Boolean, depending on success
  2108. *
  2109. * @example
  2110. * <pre>
  2111. * // Get ten slowLog entries
  2112. * $redis->slowLog('get', 10);
  2113. * // Get the default number of slowLog entries
  2114. *
  2115. * $redis->slowLog('get');
  2116. * // Reset our slowLog
  2117. * $redis->slowLog('reset');
  2118. *
  2119. * // Retrieve slowLog length
  2120. * $redis->slowLog('len');
  2121. * </pre>
  2122. *
  2123. * @link https://redis.io/commands/slowlog
  2124. */
  2125. public function slowLog(string $operation, int $length = null)
  2126. {
  2127. }
  2128. /**
  2129. * Describes the object pointed to by a key.
  2130. * The information to retrieve (string) and the key (string).
  2131. * Info can be one of the following:
  2132. * - "encoding"
  2133. * - "refcount"
  2134. * - "idletime"
  2135. *
  2136. * @param string $string
  2137. * @param string $key
  2138. *
  2139. * @return string|int|bool for "encoding", int for "refcount" and "idletime", FALSE if the key doesn't exist.
  2140. *
  2141. * @link https://redis.io/commands/object
  2142. * @example
  2143. * <pre>
  2144. * $redis->lPush('l', 'Hello, world!');
  2145. * $redis->object("encoding", "l"); // → ziplist
  2146. * $redis->object("refcount", "l"); // → 1
  2147. * $redis->object("idletime", "l"); // → 400 (in seconds, with a precision of 10 seconds).
  2148. * </pre>
  2149. */
  2150. public function object($string = '', $key = '')
  2151. {
  2152. }
  2153. /**
  2154. * Performs a synchronous save.
  2155. *
  2156. * @return bool TRUE in case of success, FALSE in case of failure
  2157. * If a save is already running, this command will fail and return FALSE.
  2158. *
  2159. * @link https://redis.io/commands/save
  2160. * @example $redis->save();
  2161. */
  2162. public function save()
  2163. {
  2164. }
  2165. /**
  2166. * Performs a background save.
  2167. *
  2168. * @return bool TRUE in case of success, FALSE in case of failure
  2169. * If a save is already running, this command will fail and return FALSE
  2170. *
  2171. * @link https://redis.io/commands/bgsave
  2172. * @example $redis->bgSave();
  2173. */
  2174. public function bgsave()
  2175. {
  2176. }
  2177. /**
  2178. * Returns the timestamp of the last disk save.
  2179. *
  2180. * @return int timestamp
  2181. *
  2182. * @link https://redis.io/commands/lastsave
  2183. * @example $redis->lastSave();
  2184. */
  2185. public function lastSave()
  2186. {
  2187. }
  2188. /**
  2189. * Blocks the current client until all the previous write commands are successfully transferred and
  2190. * acknowledged by at least the specified number of slaves.
  2191. *
  2192. * @param int $numSlaves Number of slaves that need to acknowledge previous write commands.
  2193. * @param int $timeout Timeout in milliseconds.
  2194. *
  2195. * @return int The command returns the number of slaves reached by all the writes performed in the
  2196. * context of the current connection
  2197. *
  2198. * @link https://redis.io/commands/wait
  2199. * @example $redis->wait(2, 1000);
  2200. */
  2201. public function wait($numSlaves, $timeout)
  2202. {
  2203. }
  2204. /**
  2205. * Returns the type of data pointed by a given key.
  2206. *
  2207. * @param string $key
  2208. *
  2209. * @return int
  2210. * Depending on the type of the data pointed by the key,
  2211. * this method will return the following value:
  2212. * - string: Redis::REDIS_STRING
  2213. * - set: Redis::REDIS_SET
  2214. * - list: Redis::REDIS_LIST
  2215. * - zset: Redis::REDIS_ZSET
  2216. * - hash: Redis::REDIS_HASH
  2217. * - other: Redis::REDIS_NOT_FOUND
  2218. *
  2219. * @link https://redis.io/commands/type
  2220. * @example $redis->type('key');
  2221. */
  2222. public function type($key)
  2223. {
  2224. }
  2225. /**
  2226. * Append specified string to the string stored in specified key.
  2227. *
  2228. * @param string $key
  2229. * @param string|mixed $value
  2230. *
  2231. * @return int Size of the value after the append
  2232. *
  2233. * @link https://redis.io/commands/append
  2234. * @example
  2235. * <pre>
  2236. * $redis->set('key', 'value1');
  2237. * $redis->append('key', 'value2'); // 12
  2238. * $redis->get('key'); // 'value1value2'
  2239. * </pre>
  2240. */
  2241. public function append($key, $value)
  2242. {
  2243. }
  2244. /**
  2245. * Return a substring of a larger string
  2246. *
  2247. * @param string $key
  2248. * @param int $start
  2249. * @param int $end
  2250. *
  2251. * @return string the substring
  2252. *
  2253. * @link https://redis.io/commands/getrange
  2254. * @example
  2255. * <pre>
  2256. * $redis->set('key', 'string value');
  2257. * $redis->getRange('key', 0, 5); // 'string'
  2258. * $redis->getRange('key', -5, -1); // 'value'
  2259. * </pre>
  2260. */
  2261. public function getRange($key, $start, $end)
  2262. {
  2263. }
  2264. /**
  2265. * Return a substring of a larger string
  2266. *
  2267. * @deprecated
  2268. * @param string $key
  2269. * @param int $start
  2270. * @param int $end
  2271. */
  2272. public function substr($key, $start, $end)
  2273. {
  2274. }
  2275. /**
  2276. * Changes a substring of a larger string.
  2277. *
  2278. * @param string $key
  2279. * @param int $offset
  2280. * @param string $value
  2281. *
  2282. * @return int the length of the string after it was modified
  2283. *
  2284. * @link https://redis.io/commands/setrange
  2285. * @example
  2286. * <pre>
  2287. * $redis->set('key', 'Hello world');
  2288. * $redis->setRange('key', 6, "redis"); // returns 11
  2289. * $redis->get('key'); // "Hello redis"
  2290. * </pre>
  2291. */
  2292. public function setRange($key, $offset, $value)
  2293. {
  2294. }
  2295. /**
  2296. * Get the length of a string value.
  2297. *
  2298. * @param string $key
  2299. * @return int
  2300. *
  2301. * @link https://redis.io/commands/strlen
  2302. * @example
  2303. * <pre>
  2304. * $redis->set('key', 'value');
  2305. * $redis->strlen('key'); // 5
  2306. * </pre>
  2307. */
  2308. public function strlen($key)
  2309. {
  2310. }
  2311. /**
  2312. * Return the position of the first bit set to 1 or 0 in a string. The position is returned, thinking of the
  2313. * string as an array of bits from left to right, where the first byte's most significant bit is at position 0,
  2314. * the second byte's most significant bit is at position 8, and so forth.
  2315. *
  2316. * @param string $key
  2317. * @param int $bit
  2318. * @param int $start
  2319. * @param int $end
  2320. *
  2321. * @return int The command returns the position of the first bit set to 1 or 0 according to the request.
  2322. * If we look for set bits (the bit argument is 1) and the string is empty or composed of just
  2323. * zero bytes, -1 is returned. If we look for clear bits (the bit argument is 0) and the string
  2324. * only contains bit set to 1, the function returns the first bit not part of the string on the
  2325. * right. So if the string is three bytes set to the value 0xff the command BITPOS key 0 will
  2326. * return 24, since up to bit 23 all the bits are 1. Basically, the function considers the right
  2327. * of the string as padded with zeros if you look for clear bits and specify no range or the
  2328. * start argument only. However, this behavior changes if you are looking for clear bits and
  2329. * specify a range with both start and end. If no clear bit is found in the specified range, the
  2330. * function returns -1 as the user specified a clear range and there are no 0 bits in that range.
  2331. *
  2332. * @link https://redis.io/commands/bitpos
  2333. * @example
  2334. * <pre>
  2335. * $redis->set('key', '\xff\xff');
  2336. * $redis->bitpos('key', 1); // int(0)
  2337. * $redis->bitpos('key', 1, 1); // int(8)
  2338. * $redis->bitpos('key', 1, 3); // int(-1)
  2339. * $redis->bitpos('key', 0); // int(16)
  2340. * $redis->bitpos('key', 0, 1); // int(16)
  2341. * $redis->bitpos('key', 0, 1, 5); // int(-1)
  2342. * </pre>
  2343. */
  2344. public function bitpos($key, $bit, $start = 0, $end = null)
  2345. {
  2346. }
  2347. /**
  2348. * Return a single bit out of a larger string
  2349. *
  2350. * @param string $key
  2351. * @param int $offset
  2352. *
  2353. * @return int the bit value (0 or 1)
  2354. *
  2355. * @link https://redis.io/commands/getbit
  2356. * @example
  2357. * <pre>
  2358. * $redis->set('key', "\x7f"); // this is 0111 1111
  2359. * $redis->getBit('key', 0); // 0
  2360. * $redis->getBit('key', 1); // 1
  2361. * </pre>
  2362. */
  2363. public function getBit($key, $offset)
  2364. {
  2365. }
  2366. /**
  2367. * Changes a single bit of a string.
  2368. *
  2369. * @param string $key
  2370. * @param int $offset
  2371. * @param bool|int $value bool or int (1 or 0)
  2372. *
  2373. * @return int 0 or 1, the value of the bit before it was set
  2374. *
  2375. * @link https://redis.io/commands/setbit
  2376. * @example
  2377. * <pre>
  2378. * $redis->set('key', "*"); // ord("*") = 42 = 0x2f = "0010 1010"
  2379. * $redis->setBit('key', 5, 1); // returns 0
  2380. * $redis->setBit('key', 7, 1); // returns 0
  2381. * $redis->get('key'); // chr(0x2f) = "/" = b("0010 1111")
  2382. * </pre>
  2383. */
  2384. public function setBit($key, $offset, $value)
  2385. {
  2386. }
  2387. /**
  2388. * Count bits in a string
  2389. *
  2390. * @param string $key
  2391. *
  2392. * @return int The number of bits set to 1 in the value behind the input key
  2393. *
  2394. * @link https://redis.io/commands/bitcount
  2395. * @example
  2396. * <pre>
  2397. * $redis->set('bit', '345'); // // 11 0011 0011 0100 0011 0101
  2398. * var_dump( $redis->bitCount('bit', 0, 0) ); // int(4)
  2399. * var_dump( $redis->bitCount('bit', 1, 1) ); // int(3)
  2400. * var_dump( $redis->bitCount('bit', 2, 2) ); // int(4)
  2401. * var_dump( $redis->bitCount('bit', 0, 2) ); // int(11)
  2402. * </pre>
  2403. */
  2404. public function bitCount($key)
  2405. {
  2406. }
  2407. /**
  2408. * Bitwise operation on multiple keys.
  2409. *
  2410. * @param string $operation either "AND", "OR", "NOT", "XOR"
  2411. * @param string $retKey return key
  2412. * @param string $key1 first key
  2413. * @param string ...$otherKeys variadic list of keys
  2414. *
  2415. * @return int The size of the string stored in the destination key
  2416. *
  2417. * @link https://redis.io/commands/bitop
  2418. * @example
  2419. * <pre>
  2420. * $redis->set('bit1', '1'); // 11 0001
  2421. * $redis->set('bit2', '2'); // 11 0010
  2422. *
  2423. * $redis->bitOp('AND', 'bit', 'bit1', 'bit2'); // bit = 110000
  2424. * $redis->bitOp('OR', 'bit', 'bit1', 'bit2'); // bit = 110011
  2425. * $redis->bitOp('NOT', 'bit', 'bit1', 'bit2'); // bit = 110011
  2426. * $redis->bitOp('XOR', 'bit', 'bit1', 'bit2'); // bit = 11
  2427. * </pre>
  2428. */
  2429. public function bitOp($operation, $retKey, $key1, ...$otherKeys)
  2430. {
  2431. }
  2432. /**
  2433. * Removes all entries from the current database.
  2434. *
  2435. * @return bool Always TRUE
  2436. * @link https://redis.io/commands/flushdb
  2437. * @example $redis->flushDB();
  2438. */
  2439. public function flushDB()
  2440. {
  2441. }
  2442. /**
  2443. * Removes all entries from all databases.
  2444. *
  2445. * @return bool Always TRUE
  2446. *
  2447. * @link https://redis.io/commands/flushall
  2448. * @example $redis->flushAll();
  2449. */
  2450. public function flushAll()
  2451. {
  2452. }
  2453. /**
  2454. * Sort
  2455. *
  2456. * @param string $key
  2457. * @param array $option array(key => value, ...) - optional, with the following keys and values:
  2458. * - 'by' => 'some_pattern_*',
  2459. * - 'limit' => array(0, 1),
  2460. * - 'get' => 'some_other_pattern_*' or an array of patterns,
  2461. * - 'sort' => 'asc' or 'desc',
  2462. * - 'alpha' => TRUE,
  2463. * - 'store' => 'external-key'
  2464. *
  2465. * @return array
  2466. * An array of values, or a number corresponding to the number of elements stored if that was used
  2467. *
  2468. * @link https://redis.io/commands/sort
  2469. * @example
  2470. * <pre>
  2471. * $redis->del('s');
  2472. * $redis->sadd('s', 5);
  2473. * $redis->sadd('s', 4);
  2474. * $redis->sadd('s', 2);
  2475. * $redis->sadd('s', 1);
  2476. * $redis->sadd('s', 3);
  2477. *
  2478. * var_dump($redis->sort('s')); // 1,2,3,4,5
  2479. * var_dump($redis->sort('s', array('sort' => 'desc'))); // 5,4,3,2,1
  2480. * var_dump($redis->sort('s', array('sort' => 'desc', 'store' => 'out'))); // (int)5
  2481. * </pre>
  2482. */
  2483. public function sort($key, $option = null)
  2484. {
  2485. }
  2486. /**
  2487. * Returns an associative array of strings and integers
  2488. *
  2489. * @param string $option Optional. The option to provide redis.
  2490. * SERVER | CLIENTS | MEMORY | PERSISTENCE | STATS | REPLICATION | CPU | CLASTER | KEYSPACE | COMANDSTATS
  2491. *
  2492. * Returns an associative array of strings and integers, with the following keys:
  2493. * - redis_version
  2494. * - redis_git_sha1
  2495. * - redis_git_dirty
  2496. * - arch_bits
  2497. * - multiplexing_api
  2498. * - process_id
  2499. * - uptime_in_seconds
  2500. * - uptime_in_days
  2501. * - lru_clock
  2502. * - used_cpu_sys
  2503. * - used_cpu_user
  2504. * - used_cpu_sys_children
  2505. * - used_cpu_user_children
  2506. * - connected_clients
  2507. * - connected_slaves
  2508. * - client_longest_output_list
  2509. * - client_biggest_input_buf
  2510. * - blocked_clients
  2511. * - used_memory
  2512. * - used_memory_human
  2513. * - used_memory_peak
  2514. * - used_memory_peak_human
  2515. * - mem_fragmentation_ratio
  2516. * - mem_allocator
  2517. * - loading
  2518. * - aof_enabled
  2519. * - changes_since_last_save
  2520. * - bgsave_in_progress
  2521. * - last_save_time
  2522. * - total_connections_received
  2523. * - total_commands_processed
  2524. * - expired_keys
  2525. * - evicted_keys
  2526. * - keyspace_hits
  2527. * - keyspace_misses
  2528. * - hash_max_zipmap_entries
  2529. * - hash_max_zipmap_value
  2530. * - pubsub_channels
  2531. * - pubsub_patterns
  2532. * - latest_fork_usec
  2533. * - vm_enabled
  2534. * - role
  2535. *
  2536. * @return string
  2537. *
  2538. * @link https://redis.io/commands/info
  2539. * @example
  2540. * <pre>
  2541. * $redis->info();
  2542. *
  2543. * or
  2544. *
  2545. * $redis->info("COMMANDSTATS"); //Information on the commands that have been run (>=2.6 only)
  2546. * $redis->info("CPU"); // just CPU information from Redis INFO
  2547. * </pre>
  2548. */
  2549. public function info($option = null)
  2550. {
  2551. }
  2552. /**
  2553. * Resets the statistics reported by Redis using the INFO command (`info()` function).
  2554. * These are the counters that are reset:
  2555. * - Keyspace hits
  2556. * - Keyspace misses
  2557. * - Number of commands processed
  2558. * - Number of connections received
  2559. * - Number of expired keys
  2560. *
  2561. * @return bool `TRUE` in case of success, `FALSE` in case of failure.
  2562. *
  2563. * @example $redis->resetStat();
  2564. * @link https://redis.io/commands/config-resetstat
  2565. */
  2566. public function resetStat()
  2567. {
  2568. }
  2569. /**
  2570. * Returns the time to live left for a given key, in seconds. If the key doesn't exist, FALSE is returned.
  2571. *
  2572. * @param string $key
  2573. *
  2574. * @return int|bool the time left to live in seconds
  2575. *
  2576. * @link https://redis.io/commands/ttl
  2577. * @example
  2578. * <pre>
  2579. * $redis->setex('key', 123, 'test');
  2580. * $redis->ttl('key'); // int(123)
  2581. * </pre>
  2582. */
  2583. public function ttl($key)
  2584. {
  2585. }
  2586. /**
  2587. * Returns a time to live left for a given key, in milliseconds.
  2588. *
  2589. * If the key doesn't exist, FALSE is returned.
  2590. *
  2591. * @param string $key
  2592. *
  2593. * @return int|bool the time left to live in milliseconds
  2594. *
  2595. * @link https://redis.io/commands/pttl
  2596. * @example
  2597. * <pre>
  2598. * $redis->setex('key', 123, 'test');
  2599. * $redis->pttl('key'); // int(122999)
  2600. * </pre>
  2601. */
  2602. public function pttl($key)
  2603. {
  2604. }
  2605. /**
  2606. * Remove the expiration timer from a key.
  2607. *
  2608. * @param string $key
  2609. *
  2610. * @return bool TRUE if a timeout was removed, FALSE if the key didn’t exist or didn’t have an expiration timer.
  2611. *
  2612. * @link https://redis.io/commands/persist
  2613. * @example $redis->persist('key');
  2614. */
  2615. public function persist($key)
  2616. {
  2617. }
  2618. /**
  2619. * Sets multiple key-value pairs in one atomic command.
  2620. * MSETNX only returns TRUE if all the keys were set (see SETNX).
  2621. *
  2622. * @param array $array Pairs: array(key => value, ...)
  2623. *
  2624. * @return bool TRUE in case of success, FALSE in case of failure
  2625. *
  2626. * @link https://redis.io/commands/mset
  2627. * @example
  2628. * <pre>
  2629. * $redis->mset(array('key0' => 'value0', 'key1' => 'value1'));
  2630. * var_dump($redis->get('key0'));
  2631. * var_dump($redis->get('key1'));
  2632. * // Output:
  2633. * // string(6) "value0"
  2634. * // string(6) "value1"
  2635. * </pre>
  2636. */
  2637. public function mset(array $array)
  2638. {
  2639. }
  2640. /**
  2641. * Get the values of all the specified keys.
  2642. * If one or more keys dont exist, the array will contain FALSE at the position of the key.
  2643. *
  2644. * @param array $keys Array containing the list of the keys
  2645. *
  2646. * @return array Array containing the values related to keys in argument
  2647. *
  2648. * @deprecated use Redis::mGet()
  2649. * @example
  2650. * <pre>
  2651. * $redis->set('key1', 'value1');
  2652. * $redis->set('key2', 'value2');
  2653. * $redis->set('key3', 'value3');
  2654. * $redis->getMultiple(array('key1', 'key2', 'key3')); // array('value1', 'value2', 'value3');
  2655. * $redis->getMultiple(array('key0', 'key1', 'key5')); // array(`FALSE`, 'value2', `FALSE`);
  2656. * </pre>
  2657. */
  2658. public function getMultiple(array $keys)
  2659. {
  2660. }
  2661. /**
  2662. * Returns the values of all specified keys.
  2663. *
  2664. * For every key that does not hold a string value or does not exist,
  2665. * the special value false is returned. Because of this, the operation never fails.
  2666. *
  2667. * @param array $array
  2668. *
  2669. * @return array
  2670. *
  2671. * @link https://redis.io/commands/mget
  2672. * @example
  2673. * <pre>
  2674. * $redis->del('x', 'y', 'z', 'h'); // remove x y z
  2675. * $redis->mset(array('x' => 'a', 'y' => 'b', 'z' => 'c'));
  2676. * $redis->hset('h', 'field', 'value');
  2677. * var_dump($redis->mget(array('x', 'y', 'z', 'h')));
  2678. * // Output:
  2679. * // array(3) {
  2680. * // [0]=> string(1) "a"
  2681. * // [1]=> string(1) "b"
  2682. * // [2]=> string(1) "c"
  2683. * // [3]=> bool(false)
  2684. * // }
  2685. * </pre>
  2686. */
  2687. public function mget(array $array)
  2688. {
  2689. }
  2690. /**
  2691. * @see mset()
  2692. * @param array $array
  2693. * @return int 1 (if the keys were set) or 0 (no key was set)
  2694. *
  2695. * @link https://redis.io/commands/msetnx
  2696. */
  2697. public function msetnx(array $array)
  2698. {
  2699. }
  2700. /**
  2701. * Pops a value from the tail of a list, and pushes it to the front of another list.
  2702. * Also return this value.
  2703. *
  2704. * @since redis >= 1.1
  2705. *
  2706. * @param string $srcKey
  2707. * @param string $dstKey
  2708. *
  2709. * @return string|mixed|bool The element that was moved in case of success, FALSE in case of failure.
  2710. *
  2711. * @link https://redis.io/commands/rpoplpush
  2712. * @example
  2713. * <pre>
  2714. * $redis->del('x', 'y');
  2715. *
  2716. * $redis->lPush('x', 'abc');
  2717. * $redis->lPush('x', 'def');
  2718. * $redis->lPush('y', '123');
  2719. * $redis->lPush('y', '456');
  2720. *
  2721. * // move the last of x to the front of y.
  2722. * var_dump($redis->rpoplpush('x', 'y'));
  2723. * var_dump($redis->lRange('x', 0, -1));
  2724. * var_dump($redis->lRange('y', 0, -1));
  2725. *
  2726. * //Output:
  2727. * //
  2728. * //string(3) "abc"
  2729. * //array(1) {
  2730. * // [0]=>
  2731. * // string(3) "def"
  2732. * //}
  2733. * //array(3) {
  2734. * // [0]=>
  2735. * // string(3) "abc"
  2736. * // [1]=>
  2737. * // string(3) "456"
  2738. * // [2]=>
  2739. * // string(3) "123"
  2740. * //}
  2741. * </pre>
  2742. */
  2743. public function rpoplpush($srcKey, $dstKey)
  2744. {
  2745. }
  2746. /**
  2747. * A blocking version of rpoplpush, with an integral timeout in the third parameter.
  2748. *
  2749. * @param string $srcKey
  2750. * @param string $dstKey
  2751. * @param int $timeout
  2752. *
  2753. * @return string|mixed|bool The element that was moved in case of success, FALSE in case of timeout
  2754. *
  2755. * @link https://redis.io/commands/brpoplpush
  2756. */
  2757. public function brpoplpush($srcKey, $dstKey, $timeout)
  2758. {
  2759. }
  2760. /**
  2761. * Adds the specified member with a given score to the sorted set stored at key
  2762. *
  2763. * @param string $key Required key
  2764. * @param array $options Options if needed
  2765. * @param float $score1 Required score
  2766. * @param string|mixed $value1 Required value
  2767. * @param float $score2 Optional score
  2768. * @param string|mixed $value2 Optional value
  2769. * @param float $scoreN Optional score
  2770. * @param string|mixed $valueN Optional value
  2771. *
  2772. * @return int Number of values added
  2773. *
  2774. * @link https://redis.io/commands/zadd
  2775. * @example
  2776. * <pre>
  2777. * <pre>
  2778. * $redis->zAdd('z', 1, 'v1', 2, 'v2', 3, 'v3', 4, 'v4' ); // int(2)
  2779. * $redis->zRem('z', 'v2', 'v3'); // int(2)
  2780. * $redis->zAdd('z', ['NX'], 5, 'v5'); // int(1)
  2781. * $redis->zAdd('z', ['NX'], 6, 'v5'); // int(0)
  2782. * $redis->zAdd('z', 7, 'v6'); // int(1)
  2783. * $redis->zAdd('z', 8, 'v6'); // int(0)
  2784. *
  2785. * var_dump( $redis->zRange('z', 0, -1) );
  2786. * // Output:
  2787. * // array(4) {
  2788. * // [0]=> string(2) "v1"
  2789. * // [1]=> string(2) "v4"
  2790. * // [2]=> string(2) "v5"
  2791. * // [3]=> string(2) "v8"
  2792. * // }
  2793. *
  2794. * var_dump( $redis->zRange('z', 0, -1, true) );
  2795. * // Output:
  2796. * // array(4) {
  2797. * // ["v1"]=> float(1)
  2798. * // ["v4"]=> float(4)
  2799. * // ["v5"]=> float(5)
  2800. * // ["v6"]=> float(8)
  2801. * </pre>
  2802. * </pre>
  2803. */
  2804. public function zAdd($key, $options, $score1, $value1, $score2 = null, $value2 = null, $scoreN = null, $valueN = null)
  2805. {
  2806. }
  2807. /**
  2808. * Returns a range of elements from the ordered set stored at the specified key,
  2809. * with values in the range [start, end]. start and stop are interpreted as zero-based indices:
  2810. * 0 the first element,
  2811. * 1 the second ...
  2812. * -1 the last element,
  2813. * -2 the penultimate ...
  2814. *
  2815. * @param string $key
  2816. * @param int $start
  2817. * @param int $end
  2818. * @param bool $withscores
  2819. *
  2820. * @return array Array containing the values in specified range.
  2821. *
  2822. * @link https://redis.io/commands/zrange
  2823. * @example
  2824. * <pre>
  2825. * $redis->zAdd('key1', 0, 'val0');
  2826. * $redis->zAdd('key1', 2, 'val2');
  2827. * $redis->zAdd('key1', 10, 'val10');
  2828. * $redis->zRange('key1', 0, -1); // array('val0', 'val2', 'val10')
  2829. * // with scores
  2830. * $redis->zRange('key1', 0, -1, true); // array('val0' => 0, 'val2' => 2, 'val10' => 10)
  2831. * </pre>
  2832. */
  2833. public function zRange($key, $start, $end, $withscores = null)
  2834. {
  2835. }
  2836. /**
  2837. * Deletes a specified member from the ordered set.
  2838. *
  2839. * @param string $key
  2840. * @param string|mixed $member1
  2841. * @param string|mixed ...$otherMembers
  2842. *
  2843. * @return int Number of deleted values
  2844. *
  2845. * @link https://redis.io/commands/zrem
  2846. * @example
  2847. * <pre>
  2848. * $redis->zAdd('z', 1, 'v1', 2, 'v2', 3, 'v3', 4, 'v4' ); // int(2)
  2849. * $redis->zRem('z', 'v2', 'v3'); // int(2)
  2850. * var_dump( $redis->zRange('z', 0, -1) );
  2851. * //// Output:
  2852. * // array(2) {
  2853. * // [0]=> string(2) "v1"
  2854. * // [1]=> string(2) "v4"
  2855. * // }
  2856. * </pre>
  2857. */
  2858. public function zRem($key, $member1, ...$otherMembers)
  2859. {
  2860. }
  2861. /**
  2862. * @see zRem()
  2863. * @link https://redis.io/commands/zrem
  2864. * @deprecated use Redis::zRem()
  2865. *
  2866. * @param string $key
  2867. * @param string|mixed $member1
  2868. * @param string|mixed ...$otherMembers
  2869. *
  2870. * @return int Number of deleted values
  2871. */
  2872. public function zDelete($key, $member1, ...$otherMembers)
  2873. {
  2874. }
  2875. /**
  2876. * Returns the elements of the sorted set stored at the specified key in the range [start, end]
  2877. * in reverse order. start and stop are interpretated as zero-based indices:
  2878. * 0 the first element,
  2879. * 1 the second ...
  2880. * -1 the last element,
  2881. * -2 the penultimate ...
  2882. *
  2883. * @param string $key
  2884. * @param int $start
  2885. * @param int $end
  2886. * @param bool $withscore
  2887. *
  2888. * @return array Array containing the values in specified range.
  2889. *
  2890. * @link https://redis.io/commands/zrevrange
  2891. * @example
  2892. * <pre>
  2893. * $redis->zAdd('key', 0, 'val0');
  2894. * $redis->zAdd('key', 2, 'val2');
  2895. * $redis->zAdd('key', 10, 'val10');
  2896. * $redis->zRevRange('key', 0, -1); // array('val10', 'val2', 'val0')
  2897. *
  2898. * // with scores
  2899. * $redis->zRevRange('key', 0, -1, true); // array('val10' => 10, 'val2' => 2, 'val0' => 0)
  2900. * </pre>
  2901. */
  2902. public function zRevRange($key, $start, $end, $withscore = null)
  2903. {
  2904. }
  2905. /**
  2906. * Returns the elements of the sorted set stored at the specified key which have scores in the
  2907. * range [start,end]. Adding a parenthesis before start or end excludes it from the range.
  2908. * +inf and -inf are also valid limits.
  2909. *
  2910. * zRevRangeByScore returns the same items in reverse order, when the start and end parameters are swapped.
  2911. *
  2912. * @param string $key
  2913. * @param int $start
  2914. * @param int $end
  2915. * @param array $options Two options are available:
  2916. * - withscores => TRUE,
  2917. * - and limit => array($offset, $count)
  2918. *
  2919. * @return array Array containing the values in specified range.
  2920. *
  2921. * @link https://redis.io/commands/zrangebyscore
  2922. * @example
  2923. * <pre>
  2924. * $redis->zAdd('key', 0, 'val0');
  2925. * $redis->zAdd('key', 2, 'val2');
  2926. * $redis->zAdd('key', 10, 'val10');
  2927. * $redis->zRangeByScore('key', 0, 3); // array('val0', 'val2')
  2928. * $redis->zRangeByScore('key', 0, 3, array('withscores' => TRUE); // array('val0' => 0, 'val2' => 2)
  2929. * $redis->zRangeByScore('key', 0, 3, array('limit' => array(1, 1)); // array('val2')
  2930. * $redis->zRangeByScore('key', 0, 3, array('withscores' => TRUE, 'limit' => array(1, 1)); // array('val2' => 2)
  2931. * </pre>
  2932. */
  2933. public function zRangeByScore($key, $start, $end, array $options = array())
  2934. {
  2935. }
  2936. /**
  2937. * @see zRangeByScore()
  2938. * @param string $key
  2939. * @param int $start
  2940. * @param int $end
  2941. * @param array $options
  2942. *
  2943. * @return array
  2944. */
  2945. public function zRevRangeByScore($key, $start, $end, array $options = array())
  2946. {
  2947. }
  2948. /**
  2949. * Returns a lexigraphical range of members in a sorted set, assuming the members have the same score. The
  2950. * min and max values are required to start with '(' (exclusive), '[' (inclusive), or be exactly the values
  2951. * '-' (negative inf) or '+' (positive inf). The command must be called with either three *or* five
  2952. * arguments or will return FALSE.
  2953. *
  2954. * @param string $key The ZSET you wish to run against.
  2955. * @param int $min The minimum alphanumeric value you wish to get.
  2956. * @param int $max The maximum alphanumeric value you wish to get.
  2957. * @param int $offset Optional argument if you wish to start somewhere other than the first element.
  2958. * @param int $limit Optional argument if you wish to limit the number of elements returned.
  2959. *
  2960. * @return array|bool Array containing the values in the specified range.
  2961. *
  2962. * @link https://redis.io/commands/zrangebylex
  2963. * @example
  2964. * <pre>
  2965. * foreach (array('a', 'b', 'c', 'd', 'e', 'f', 'g') as $char) {
  2966. * $redis->zAdd('key', $char);
  2967. * }
  2968. *
  2969. * $redis->zRangeByLex('key', '-', '[c'); // array('a', 'b', 'c')
  2970. * $redis->zRangeByLex('key', '-', '(c'); // array('a', 'b')
  2971. * $redis->zRangeByLex('key', '-', '[c'); // array('b', 'c')
  2972. * </pre>
  2973. */
  2974. public function zRangeByLex($key, $min, $max, $offset = null, $limit = null)
  2975. {
  2976. }
  2977. /**
  2978. * @see zRangeByLex()
  2979. * @param string $key
  2980. * @param int $min
  2981. * @param int $max
  2982. * @param int $offset
  2983. * @param int $limit
  2984. *
  2985. * @return array
  2986. *
  2987. * @link https://redis.io/commands/zrevrangebylex
  2988. */
  2989. public function zRevRangeByLex($key, $min, $max, $offset = null, $limit = null)
  2990. {
  2991. }
  2992. /**
  2993. * Returns the number of elements of the sorted set stored at the specified key which have
  2994. * scores in the range [start,end]. Adding a parenthesis before start or end excludes it
  2995. * from the range. +inf and -inf are also valid limits.
  2996. *
  2997. * @param string $key
  2998. * @param string $start
  2999. * @param string $end
  3000. *
  3001. * @return int the size of a corresponding zRangeByScore
  3002. *
  3003. * @link https://redis.io/commands/zcount
  3004. * @example
  3005. * <pre>
  3006. * $redis->zAdd('key', 0, 'val0');
  3007. * $redis->zAdd('key', 2, 'val2');
  3008. * $redis->zAdd('key', 10, 'val10');
  3009. * $redis->zCount('key', 0, 3); // 2, corresponding to array('val0', 'val2')
  3010. * </pre>
  3011. */
  3012. public function zCount($key, $start, $end)
  3013. {
  3014. }
  3015. /**
  3016. * Deletes the elements of the sorted set stored at the specified key which have scores in the range [start,end].
  3017. *
  3018. * @param string $key
  3019. * @param float|string $start double or "+inf" or "-inf" string
  3020. * @param float|string $end double or "+inf" or "-inf" string
  3021. *
  3022. * @return int The number of values deleted from the sorted set
  3023. *
  3024. * @link https://redis.io/commands/zremrangebyscore
  3025. * @example
  3026. * <pre>
  3027. * $redis->zAdd('key', 0, 'val0');
  3028. * $redis->zAdd('key', 2, 'val2');
  3029. * $redis->zAdd('key', 10, 'val10');
  3030. * $redis->zRemRangeByScore('key', 0, 3); // 2
  3031. * </pre>
  3032. */
  3033. public function zRemRangeByScore($key, $start, $end)
  3034. {
  3035. }
  3036. /**
  3037. * @see zRemRangeByScore()
  3038. * @deprecated use Redis::zRemRangeByScore()
  3039. *
  3040. * @param string $key
  3041. * @param float $start
  3042. * @param float $end
  3043. */
  3044. public function zDeleteRangeByScore($key, $start, $end)
  3045. {
  3046. }
  3047. /**
  3048. * Deletes the elements of the sorted set stored at the specified key which have rank in the range [start,end].
  3049. *
  3050. * @param string $key
  3051. * @param int $start
  3052. * @param int $end
  3053. *
  3054. * @return int The number of values deleted from the sorted set
  3055. *
  3056. * @link https://redis.io/commands/zremrangebyrank
  3057. * @example
  3058. * <pre>
  3059. * $redis->zAdd('key', 1, 'one');
  3060. * $redis->zAdd('key', 2, 'two');
  3061. * $redis->zAdd('key', 3, 'three');
  3062. * $redis->zRemRangeByRank('key', 0, 1); // 2
  3063. * $redis->zRange('key', 0, -1, array('withscores' => TRUE)); // array('three' => 3)
  3064. * </pre>
  3065. */
  3066. public function zRemRangeByRank($key, $start, $end)
  3067. {
  3068. }
  3069. /**
  3070. * @see zRemRangeByRank()
  3071. * @link https://redis.io/commands/zremrangebyscore
  3072. * @deprecated use Redis::zRemRangeByRank()
  3073. *
  3074. * @param string $key
  3075. * @param int $start
  3076. * @param int $end
  3077. */
  3078. public function zDeleteRangeByRank($key, $start, $end)
  3079. {
  3080. }
  3081. /**
  3082. * Returns the cardinality of an ordered set.
  3083. *
  3084. * @param string $key
  3085. *
  3086. * @return int the set's cardinality
  3087. *
  3088. * @link https://redis.io/commands/zsize
  3089. * @example
  3090. * <pre>
  3091. * $redis->zAdd('key', 0, 'val0');
  3092. * $redis->zAdd('key', 2, 'val2');
  3093. * $redis->zAdd('key', 10, 'val10');
  3094. * $redis->zCard('key'); // 3
  3095. * </pre>
  3096. */
  3097. public function zCard($key)
  3098. {
  3099. }
  3100. /**
  3101. * @see zCard()
  3102. * @deprecated use Redis::zCard()
  3103. *
  3104. * @param string $key
  3105. * @return int
  3106. */
  3107. public function zSize($key)
  3108. {
  3109. }
  3110. /**
  3111. * Returns the score of a given member in the specified sorted set.
  3112. *
  3113. * @param string $key
  3114. * @param string|mixed $member
  3115. *
  3116. * @return float|bool false if member or key not exists
  3117. *
  3118. * @link https://redis.io/commands/zscore
  3119. * @example
  3120. * <pre>
  3121. * $redis->zAdd('key', 2.5, 'val2');
  3122. * $redis->zScore('key', 'val2'); // 2.5
  3123. * </pre>
  3124. */
  3125. public function zScore($key, $member)
  3126. {
  3127. }
  3128. /**
  3129. * Returns the rank of a given member in the specified sorted set, starting at 0 for the item
  3130. * with the smallest score. zRevRank starts at 0 for the item with the largest score.
  3131. *
  3132. * @param string $key
  3133. * @param string|mixed $member
  3134. *
  3135. * @return int|bool the item's score, or false if key or member is not exists
  3136. *
  3137. * @link https://redis.io/commands/zrank
  3138. * @example
  3139. * <pre>
  3140. * $redis->del('z');
  3141. * $redis->zAdd('key', 1, 'one');
  3142. * $redis->zAdd('key', 2, 'two');
  3143. * $redis->zRank('key', 'one'); // 0
  3144. * $redis->zRank('key', 'two'); // 1
  3145. * $redis->zRevRank('key', 'one'); // 1
  3146. * $redis->zRevRank('key', 'two'); // 0
  3147. * </pre>
  3148. */
  3149. public function zRank($key, $member)
  3150. {
  3151. }
  3152. /**
  3153. * @see zRank()
  3154. * @param string $key
  3155. * @param string|mixed $member
  3156. *
  3157. * @return int|bool the item's score, false - if key or member is not exists
  3158. *
  3159. * @link https://redis.io/commands/zrevrank
  3160. */
  3161. public function zRevRank($key, $member)
  3162. {
  3163. }
  3164. /**
  3165. * Increments the score of a member from a sorted set by a given amount.
  3166. *
  3167. * @param string $key
  3168. * @param float $value (double) value that will be added to the member's score
  3169. * @param string $member
  3170. *
  3171. * @return float the new value
  3172. *
  3173. * @link https://redis.io/commands/zincrby
  3174. * @example
  3175. * <pre>
  3176. * $redis->del('key');
  3177. * $redis->zIncrBy('key', 2.5, 'member1'); // key or member1 didn't exist, so member1's score is to 0
  3178. * // before the increment and now has the value 2.5
  3179. * $redis->zIncrBy('key', 1, 'member1'); // 3.5
  3180. * </pre>
  3181. */
  3182. public function zIncrBy($key, $value, $member)
  3183. {
  3184. }
  3185. /**
  3186. * Creates an union of sorted sets given in second argument.
  3187. * The result of the union will be stored in the sorted set defined by the first argument.
  3188. * The third optionnel argument defines weights to apply to the sorted sets in input.
  3189. * In this case, the weights will be multiplied by the score of each element in the sorted set
  3190. * before applying the aggregation. The forth argument defines the AGGREGATE option which
  3191. * specify how the results of the union are aggregated.
  3192. *
  3193. * @param string $output
  3194. * @param array $zSetKeys
  3195. * @param array $weights
  3196. * @param string $aggregateFunction Either "SUM", "MIN", or "MAX": defines the behaviour to use on
  3197. * duplicate entries during the zUnionStore
  3198. *
  3199. * @return int The number of values in the new sorted set
  3200. *
  3201. * @link https://redis.io/commands/zunionstore
  3202. * @example
  3203. * <pre>
  3204. * $redis->del('k1');
  3205. * $redis->del('k2');
  3206. * $redis->del('k3');
  3207. * $redis->del('ko1');
  3208. * $redis->del('ko2');
  3209. * $redis->del('ko3');
  3210. *
  3211. * $redis->zAdd('k1', 0, 'val0');
  3212. * $redis->zAdd('k1', 1, 'val1');
  3213. *
  3214. * $redis->zAdd('k2', 2, 'val2');
  3215. * $redis->zAdd('k2', 3, 'val3');
  3216. *
  3217. * $redis->zUnionStore('ko1', array('k1', 'k2')); // 4, 'ko1' => array('val0', 'val1', 'val2', 'val3')
  3218. *
  3219. * // Weighted zUnionStore
  3220. * $redis->zUnionStore('ko2', array('k1', 'k2'), array(1, 1)); // 4, 'ko2' => array('val0', 'val1', 'val2', 'val3')
  3221. * $redis->zUnionStore('ko3', array('k1', 'k2'), array(5, 1)); // 4, 'ko3' => array('val0', 'val2', 'val3', 'val1')
  3222. * </pre>
  3223. */
  3224. public function zUnionStore($output, $zSetKeys, array $weights = null, $aggregateFunction = 'SUM')
  3225. {
  3226. }
  3227. /**
  3228. * @see zUnionStore
  3229. * @deprecated use Redis::zUnionStore()
  3230. *
  3231. * @param string $Output
  3232. * @param array $ZSetKeys
  3233. * @param array|null $Weights
  3234. * @param string $aggregateFunction
  3235. */
  3236. public function zUnion($Output, $ZSetKeys, array $Weights = null, $aggregateFunction = 'SUM')
  3237. {
  3238. }
  3239. /**
  3240. * Creates an intersection of sorted sets given in second argument.
  3241. * The result of the union will be stored in the sorted set defined by the first argument.
  3242. * The third optional argument defines weights to apply to the sorted sets in input.
  3243. * In this case, the weights will be multiplied by the score of each element in the sorted set
  3244. * before applying the aggregation. The forth argument defines the AGGREGATE option which
  3245. * specify how the results of the union are aggregated.
  3246. *
  3247. * @param string $output
  3248. * @param array $zSetKeys
  3249. * @param array $weights
  3250. * @param string $aggregateFunction Either "SUM", "MIN", or "MAX":
  3251. * defines the behaviour to use on duplicate entries during the zInterStore.
  3252. *
  3253. * @return int The number of values in the new sorted set.
  3254. *
  3255. * @link https://redis.io/commands/zinterstore
  3256. * @example
  3257. * <pre>
  3258. * $redis->del('k1');
  3259. * $redis->del('k2');
  3260. * $redis->del('k3');
  3261. *
  3262. * $redis->del('ko1');
  3263. * $redis->del('ko2');
  3264. * $redis->del('ko3');
  3265. * $redis->del('ko4');
  3266. *
  3267. * $redis->zAdd('k1', 0, 'val0');
  3268. * $redis->zAdd('k1', 1, 'val1');
  3269. * $redis->zAdd('k1', 3, 'val3');
  3270. *
  3271. * $redis->zAdd('k2', 2, 'val1');
  3272. * $redis->zAdd('k2', 3, 'val3');
  3273. *
  3274. * $redis->zInterStore('ko1', array('k1', 'k2')); // 2, 'ko1' => array('val1', 'val3')
  3275. * $redis->zInterStore('ko2', array('k1', 'k2'), array(1, 1)); // 2, 'ko2' => array('val1', 'val3')
  3276. *
  3277. * // Weighted zInterStore
  3278. * $redis->zInterStore('ko3', array('k1', 'k2'), array(1, 5), 'min'); // 2, 'ko3' => array('val1', 'val3')
  3279. * $redis->zInterStore('ko4', array('k1', 'k2'), array(1, 5), 'max'); // 2, 'ko4' => array('val3', 'val1')
  3280. * </pre>
  3281. */
  3282. public function zInterStore($output, $zSetKeys, array $weights = null, $aggregateFunction = 'SUM')
  3283. {
  3284. }
  3285. /**
  3286. * @see zInterStore
  3287. * @deprecated use Redis::zInterStore()
  3288. *
  3289. * @param $Output
  3290. * @param $ZSetKeys
  3291. * @param array|null $Weights
  3292. * @param string $aggregateFunction
  3293. */
  3294. public function zInter($Output, $ZSetKeys, array $Weights = null, $aggregateFunction = 'SUM')
  3295. {
  3296. }
  3297. /**
  3298. * Scan a sorted set for members, with optional pattern and count
  3299. *
  3300. * @param string $key String, the set to scan.
  3301. * @param int $iterator Long (reference), initialized to NULL.
  3302. * @param string $pattern String (optional), the pattern to match.
  3303. * @param int $count How many keys to return per iteration (Redis might return a different number).
  3304. *
  3305. * @return array|bool PHPRedis will return matching keys from Redis, or FALSE when iteration is complete
  3306. *
  3307. * @link https://redis.io/commands/zscan
  3308. * @example
  3309. * <pre>
  3310. * $iterator = null;
  3311. * while ($members = $redis-zscan('zset', $iterator)) {
  3312. * foreach ($members as $member => $score) {
  3313. * echo $member . ' => ' . $score . PHP_EOL;
  3314. * }
  3315. * }
  3316. * </pre>
  3317. */
  3318. public function zScan($key, &$iterator, $pattern = null, $count = 0)
  3319. {
  3320. }
  3321. /**
  3322. * Block until Redis can pop the highest or lowest scoring members from one or more ZSETs.
  3323. * There are two commands (BZPOPMIN and BZPOPMAX for popping the lowest and highest scoring elements respectively.)
  3324. *
  3325. * @param string|array $key1
  3326. * @param string|array $key2 ...
  3327. * @param int $timeout
  3328. *
  3329. * @return array Either an array with the key member and score of the higest or lowest element or an empty array
  3330. * if the timeout was reached without an element to pop.
  3331. *
  3332. * @since >= 5.0
  3333. * @link https://redis.io/commands/bzpopmax
  3334. * @example
  3335. * <pre>
  3336. * // Wait up to 5 seconds to pop the *lowest* scoring member from sets `zs1` and `zs2`.
  3337. * $redis->bzPopMin(['zs1', 'zs2'], 5);
  3338. * $redis->bzPopMin('zs1', 'zs2', 5);
  3339. *
  3340. * // Wait up to 5 seconds to pop the *highest* scoring member from sets `zs1` and `zs2`
  3341. * $redis->bzPopMax(['zs1', 'zs2'], 5);
  3342. * $redis->bzPopMax('zs1', 'zs2', 5);
  3343. * </pre>
  3344. */
  3345. public function bzPopMax($key1, $key2, $timeout)
  3346. {
  3347. }
  3348. /**
  3349. * @param string|array $key1
  3350. * @param string|array $key2 ...
  3351. * @param int $timeout
  3352. *
  3353. * @return array Either an array with the key member and score of the higest or lowest element or an empty array
  3354. * if the timeout was reached without an element to pop.
  3355. *
  3356. * @see bzPopMax
  3357. * @since >= 5.0
  3358. * @link https://redis.io/commands/bzpopmin
  3359. */
  3360. public function bzPopMin($key1, $key2, $timeout)
  3361. {
  3362. }
  3363. /**
  3364. * Adds a value to the hash stored at key. If this value is already in the hash, FALSE is returned.
  3365. *
  3366. * @param string $key
  3367. * @param string $hashKey
  3368. * @param string $value
  3369. *
  3370. * @return int|bool
  3371. * - 1 if value didn't exist and was added successfully,
  3372. * - 0 if the value was already present and was replaced, FALSE if there was an error.
  3373. *
  3374. * @link https://redis.io/commands/hset
  3375. * @example
  3376. * <pre>
  3377. * $redis->del('h')
  3378. * $redis->hSet('h', 'key1', 'hello'); // 1, 'key1' => 'hello' in the hash at "h"
  3379. * $redis->hGet('h', 'key1'); // returns "hello"
  3380. *
  3381. * $redis->hSet('h', 'key1', 'plop'); // 0, value was replaced.
  3382. * $redis->hGet('h', 'key1'); // returns "plop"
  3383. * </pre>
  3384. */
  3385. public function hSet($key, $hashKey, $value)
  3386. {
  3387. }
  3388. /**
  3389. * Adds a value to the hash stored at key only if this field isn't already in the hash.
  3390. *
  3391. * @param string $key
  3392. * @param string $hashKey
  3393. * @param string $value
  3394. *
  3395. * @return bool TRUE if the field was set, FALSE if it was already present.
  3396. *
  3397. * @link https://redis.io/commands/hsetnx
  3398. * @example
  3399. * <pre>
  3400. * $redis->del('h')
  3401. * $redis->hSetNx('h', 'key1', 'hello'); // TRUE, 'key1' => 'hello' in the hash at "h"
  3402. * $redis->hSetNx('h', 'key1', 'world'); // FALSE, 'key1' => 'hello' in the hash at "h". No change since the field
  3403. * wasn't replaced.
  3404. * </pre>
  3405. */
  3406. public function hSetNx($key, $hashKey, $value)
  3407. {
  3408. }
  3409. /**
  3410. * Gets a value from the hash stored at key.
  3411. * If the hash table doesn't exist, or the key doesn't exist, FALSE is returned.
  3412. *
  3413. * @param string $key
  3414. * @param string $hashKey
  3415. *
  3416. * @return string The value, if the command executed successfully BOOL FALSE in case of failure
  3417. *
  3418. * @link https://redis.io/commands/hget
  3419. */
  3420. public function hGet($key, $hashKey)
  3421. {
  3422. }
  3423. /**
  3424. * Returns the length of a hash, in number of items
  3425. *
  3426. * @param string $key
  3427. *
  3428. * @return int|false the number of items in a hash, FALSE if the key doesn't exist or isn't a hash
  3429. *
  3430. * @link https://redis.io/commands/hlen
  3431. * @example
  3432. * <pre>
  3433. * $redis->del('h')
  3434. * $redis->hSet('h', 'key1', 'hello');
  3435. * $redis->hSet('h', 'key2', 'plop');
  3436. * $redis->hLen('h'); // returns 2
  3437. * </pre>
  3438. */
  3439. public function hLen($key)
  3440. {
  3441. }
  3442. /**
  3443. * Removes a values from the hash stored at key.
  3444. * If the hash table doesn't exist, or the key doesn't exist, FALSE is returned.
  3445. *
  3446. * @param string $key
  3447. * @param string $hashKey1
  3448. * @param string ...$otherHashKeys
  3449. *
  3450. * @return int|false Number of deleted fields
  3451. *
  3452. * @link https://redis.io/commands/hdel
  3453. * @example
  3454. * <pre>
  3455. * $redis->hMSet('h',
  3456. * array(
  3457. * 'f1' => 'v1',
  3458. * 'f2' => 'v2',
  3459. * 'f3' => 'v3',
  3460. * 'f4' => 'v4',
  3461. * ));
  3462. *
  3463. * var_dump( $redis->hDel('h', 'f1') ); // int(1)
  3464. * var_dump( $redis->hDel('h', 'f2', 'f3') ); // int(2)
  3465. * s
  3466. * var_dump( $redis->hGetAll('h') );
  3467. * //// Output:
  3468. * // array(1) {
  3469. * // ["f4"]=> string(2) "v4"
  3470. * // }
  3471. * </pre>
  3472. */
  3473. public function hDel($key, $hashKey1, ...$otherHashKeys)
  3474. {
  3475. }
  3476. /**
  3477. * Returns the keys in a hash, as an array of strings.
  3478. *
  3479. * @param string $key
  3480. *
  3481. * @return array An array of elements, the keys of the hash. This works like PHP's array_keys().
  3482. *
  3483. * @link https://redis.io/commands/hkeys
  3484. * @example
  3485. * <pre>
  3486. * $redis->del('h');
  3487. * $redis->hSet('h', 'a', 'x');
  3488. * $redis->hSet('h', 'b', 'y');
  3489. * $redis->hSet('h', 'c', 'z');
  3490. * $redis->hSet('h', 'd', 't');
  3491. * var_dump($redis->hKeys('h'));
  3492. *
  3493. * // Output:
  3494. * // array(4) {
  3495. * // [0]=>
  3496. * // string(1) "a"
  3497. * // [1]=>
  3498. * // string(1) "b"
  3499. * // [2]=>
  3500. * // string(1) "c"
  3501. * // [3]=>
  3502. * // string(1) "d"
  3503. * // }
  3504. * // The order is random and corresponds to redis' own internal representation of the set structure.
  3505. * </pre>
  3506. */
  3507. public function hKeys($key)
  3508. {
  3509. }
  3510. /**
  3511. * Returns the values in a hash, as an array of strings.
  3512. *
  3513. * @param string $key
  3514. *
  3515. * @return array An array of elements, the values of the hash. This works like PHP's array_values().
  3516. *
  3517. * @link https://redis.io/commands/hvals
  3518. * @example
  3519. * <pre>
  3520. * $redis->del('h');
  3521. * $redis->hSet('h', 'a', 'x');
  3522. * $redis->hSet('h', 'b', 'y');
  3523. * $redis->hSet('h', 'c', 'z');
  3524. * $redis->hSet('h', 'd', 't');
  3525. * var_dump($redis->hVals('h'));
  3526. *
  3527. * // Output
  3528. * // array(4) {
  3529. * // [0]=>
  3530. * // string(1) "x"
  3531. * // [1]=>
  3532. * // string(1) "y"
  3533. * // [2]=>
  3534. * // string(1) "z"
  3535. * // [3]=>
  3536. * // string(1) "t"
  3537. * // }
  3538. * // The order is random and corresponds to redis' own internal representation of the set structure.
  3539. * </pre>
  3540. */
  3541. public function hVals($key)
  3542. {
  3543. }
  3544. /**
  3545. * Returns the whole hash, as an array of strings indexed by strings.
  3546. *
  3547. * @param string $key
  3548. *
  3549. * @return array An array of elements, the contents of the hash.
  3550. *
  3551. * @link https://redis.io/commands/hgetall
  3552. * @example
  3553. * <pre>
  3554. * $redis->del('h');
  3555. * $redis->hSet('h', 'a', 'x');
  3556. * $redis->hSet('h', 'b', 'y');
  3557. * $redis->hSet('h', 'c', 'z');
  3558. * $redis->hSet('h', 'd', 't');
  3559. * var_dump($redis->hGetAll('h'));
  3560. *
  3561. * // Output:
  3562. * // array(4) {
  3563. * // ["a"]=>
  3564. * // string(1) "x"
  3565. * // ["b"]=>
  3566. * // string(1) "y"
  3567. * // ["c"]=>
  3568. * // string(1) "z"
  3569. * // ["d"]=>
  3570. * // string(1) "t"
  3571. * // }
  3572. * // The order is random and corresponds to redis' own internal representation of the set structure.
  3573. * </pre>
  3574. */
  3575. public function hGetAll($key)
  3576. {
  3577. }
  3578. /**
  3579. * Verify if the specified member exists in a key.
  3580. *
  3581. * @param string $key
  3582. * @param string $hashKey
  3583. *
  3584. * @return bool If the member exists in the hash table, return TRUE, otherwise return FALSE.
  3585. *
  3586. * @link https://redis.io/commands/hexists
  3587. * @example
  3588. * <pre>
  3589. * $redis->hSet('h', 'a', 'x');
  3590. * $redis->hExists('h', 'a'); // TRUE
  3591. * $redis->hExists('h', 'NonExistingKey'); // FALSE
  3592. * </pre>
  3593. */
  3594. public function hExists($key, $hashKey)
  3595. {
  3596. }
  3597. /**
  3598. * Increments the value of a member from a hash by a given amount.
  3599. *
  3600. * @param string $key
  3601. * @param string $hashKey
  3602. * @param int $value (integer) value that will be added to the member's value
  3603. *
  3604. * @return int the new value
  3605. *
  3606. * @link https://redis.io/commands/hincrby
  3607. * @example
  3608. * <pre>
  3609. * $redis->del('h');
  3610. * $redis->hIncrBy('h', 'x', 2); // returns 2: h[x] = 2 now.
  3611. * $redis->hIncrBy('h', 'x', 1); // h[x] ← 2 + 1. Returns 3
  3612. * </pre>
  3613. */
  3614. public function hIncrBy($key, $hashKey, $value)
  3615. {
  3616. }
  3617. /**
  3618. * Increment the float value of a hash field by the given amount
  3619. *
  3620. * @param string $key
  3621. * @param string $field
  3622. * @param float $increment
  3623. *
  3624. * @return float
  3625. *
  3626. * @link https://redis.io/commands/hincrbyfloat
  3627. * @example
  3628. * <pre>
  3629. * $redis = new Redis();
  3630. * $redis->connect('127.0.0.1');
  3631. * $redis->hset('h', 'float', 3);
  3632. * $redis->hset('h', 'int', 3);
  3633. * var_dump( $redis->hIncrByFloat('h', 'float', 1.5) ); // float(4.5)
  3634. *
  3635. * var_dump( $redis->hGetAll('h') );
  3636. *
  3637. * // Output
  3638. * array(2) {
  3639. * ["float"]=>
  3640. * string(3) "4.5"
  3641. * ["int"]=>
  3642. * string(1) "3"
  3643. * }
  3644. * </pre>
  3645. */
  3646. public function hIncrByFloat($key, $field, $increment)
  3647. {
  3648. }
  3649. /**
  3650. * Fills in a whole hash. Non-string values are converted to string, using the standard (string) cast.
  3651. * NULL values are stored as empty strings
  3652. *
  3653. * @param string $key
  3654. * @param array $hashKeys key → value array
  3655. *
  3656. * @return bool
  3657. *
  3658. * @link https://redis.io/commands/hmset
  3659. * @example
  3660. * <pre>
  3661. * $redis->del('user:1');
  3662. * $redis->hMSet('user:1', array('name' => 'Joe', 'salary' => 2000));
  3663. * $redis->hIncrBy('user:1', 'salary', 100); // Joe earns 100 more now.
  3664. * </pre>
  3665. */
  3666. public function hMSet($key, $hashKeys)
  3667. {
  3668. }
  3669. /**
  3670. * Retirieve the values associated to the specified fields in the hash.
  3671. *
  3672. * @param string $key
  3673. * @param array $hashKeys
  3674. *
  3675. * @return array Array An array of elements, the values of the specified fields in the hash,
  3676. * with the hash keys as array keys.
  3677. *
  3678. * @link https://redis.io/commands/hmget
  3679. * @example
  3680. * <pre>
  3681. * $redis->del('h');
  3682. * $redis->hSet('h', 'field1', 'value1');
  3683. * $redis->hSet('h', 'field2', 'value2');
  3684. * $redis->hmGet('h', array('field1', 'field2')); // returns array('field1' => 'value1', 'field2' => 'value2')
  3685. * </pre>
  3686. */
  3687. public function hMGet($key, $hashKeys)
  3688. {
  3689. }
  3690. /**
  3691. * Scan a HASH value for members, with an optional pattern and count.
  3692. *
  3693. * @param string $key
  3694. * @param int $iterator
  3695. * @param string $pattern Optional pattern to match against.
  3696. * @param int $count How many keys to return in a go (only a sugestion to Redis).
  3697. *
  3698. * @return array An array of members that match our pattern.
  3699. *
  3700. * @link https://redis.io/commands/hscan
  3701. * @example
  3702. * <pre>
  3703. * // $iterator = null;
  3704. * // while($elements = $redis->hscan('hash', $iterator)) {
  3705. * // foreach($elements as $key => $value) {
  3706. * // echo $key . ' => ' . $value . PHP_EOL;
  3707. * // }
  3708. * // }
  3709. * </pre>
  3710. */
  3711. public function hScan($key, &$iterator, $pattern = null, $count = 0)
  3712. {
  3713. }
  3714. /**
  3715. * Get the string length of the value associated with field in the hash stored at key
  3716. *
  3717. * @param string $key
  3718. * @param string $field
  3719. *
  3720. * @return int the string length of the value associated with field, or zero when field is not present in the hash
  3721. * or key does not exist at all.
  3722. *
  3723. * @link https://redis.io/commands/hstrlen
  3724. * @since >= 3.2
  3725. */
  3726. public function hStrLen(string $key, string $field)
  3727. {
  3728. }
  3729. /**
  3730. * Add one or more geospatial items to the specified key.
  3731. * This function must be called with at least one longitude, latitude, member triplet.
  3732. *
  3733. * @param string $key
  3734. * @param float $longitude
  3735. * @param float $latitude
  3736. * @param string $member
  3737. *
  3738. * @return int The number of elements added to the geospatial key
  3739. *
  3740. * @link https://redis.io/commands/geoadd
  3741. * @since >=3.2
  3742. *
  3743. * @example
  3744. * <pre>
  3745. * $redis->del("myplaces");
  3746. *
  3747. * // Since the key will be new, $result will be 2
  3748. * $result = $redis->geoAdd(
  3749. * "myplaces",
  3750. * -122.431, 37.773, "San Francisco",
  3751. * -157.858, 21.315, "Honolulu"
  3752. * ); // 2
  3753. * </pre>
  3754. */
  3755. public function geoadd($key, $longitude, $latitude, $member)
  3756. {
  3757. }
  3758. /**
  3759. * Retrieve Geohash strings for one or more elements of a geospatial index.
  3760. * @param string $key
  3761. * @param string ...$member variadic list of members
  3762. *
  3763. * @return array One or more Redis Geohash encoded strings
  3764. *
  3765. * @link https://redis.io/commands/geohash
  3766. * @since >=3.2
  3767. *
  3768. * @example
  3769. * <pre>
  3770. * $redis->geoAdd("hawaii", -157.858, 21.306, "Honolulu", -156.331, 20.798, "Maui");
  3771. * $hashes = $redis->geoHash("hawaii", "Honolulu", "Maui");
  3772. * var_dump($hashes);
  3773. * // Output: array(2) {
  3774. * // [0]=>
  3775. * // string(11) "87z9pyek3y0"
  3776. * // [1]=>
  3777. * // string(11) "8e8y6d5jps0"
  3778. * // }
  3779. * </pre>
  3780. */
  3781. public function geohash($key, ...$member)
  3782. {
  3783. }
  3784. /**
  3785. * Return longitude, latitude positions for each requested member.
  3786. *
  3787. * @param string $key
  3788. * @param string $member
  3789. * @return array One or more longitude/latitude positions
  3790. *
  3791. * @link https://redis.io/commands/geopos
  3792. * @since >=3.2
  3793. *
  3794. * @example
  3795. * <pre>
  3796. * $redis->geoAdd("hawaii", -157.858, 21.306, "Honolulu", -156.331, 20.798, "Maui");
  3797. * $positions = $redis->geoPos("hawaii", "Honolulu", "Maui");
  3798. * var_dump($positions);
  3799. *
  3800. * // Output:
  3801. * array(2) {
  3802. * [0]=> array(2) {
  3803. * [0]=> string(22) "-157.85800248384475708"
  3804. * [1]=> string(19) "21.3060004581273077"
  3805. * }
  3806. * [1]=> array(2) {
  3807. * [0]=> string(22) "-156.33099943399429321"
  3808. * [1]=> string(20) "20.79799924753607598"
  3809. * }
  3810. * }
  3811. * </pre>
  3812. */
  3813. public function geopos(string $key, string $member)
  3814. {
  3815. }
  3816. /**
  3817. * Return the distance between two members in a geospatial set.
  3818. *
  3819. * If units are passed it must be one of the following values:
  3820. * - 'm' => Meters
  3821. * - 'km' => Kilometers
  3822. * - 'mi' => Miles
  3823. * - 'ft' => Feet
  3824. *
  3825. * @param string $key
  3826. * @param string $member1
  3827. * @param string $member2
  3828. * @param string|null $unit
  3829. *
  3830. * @return float The distance between the two passed members in the units requested (meters by default)
  3831. *
  3832. * @link https://redis.io/commands/geodist
  3833. * @since >=3.2
  3834. *
  3835. * @example
  3836. * <pre>
  3837. * $redis->geoAdd("hawaii", -157.858, 21.306, "Honolulu", -156.331, 20.798, "Maui");
  3838. *
  3839. * $meters = $redis->geoDist("hawaii", "Honolulu", "Maui");
  3840. * $kilometers = $redis->geoDist("hawaii", "Honolulu", "Maui", 'km');
  3841. * $miles = $redis->geoDist("hawaii", "Honolulu", "Maui", 'mi');
  3842. * $feet = $redis->geoDist("hawaii", "Honolulu", "Maui", 'ft');
  3843. *
  3844. * echo "Distance between Honolulu and Maui:\n";
  3845. * echo " meters : $meters\n";
  3846. * echo " kilometers: $kilometers\n";
  3847. * echo " miles : $miles\n";
  3848. * echo " feet : $feet\n";
  3849. *
  3850. * // Bad unit
  3851. * $inches = $redis->geoDist("hawaii", "Honolulu", "Maui", 'in');
  3852. * echo "Invalid unit returned:\n";
  3853. * var_dump($inches);
  3854. *
  3855. * // Output
  3856. * Distance between Honolulu and Maui:
  3857. * meters : 168275.204
  3858. * kilometers: 168.2752
  3859. * miles : 104.5616
  3860. * feet : 552084.0028
  3861. * Invalid unit returned:
  3862. * bool(false)
  3863. * </pre>
  3864. */
  3865. public function geodist($key, $member1, $member2, $unit = null)
  3866. {
  3867. }
  3868. /**
  3869. * Return members of a set with geospatial information that are within the radius specified by the caller.
  3870. *
  3871. * @param $key
  3872. * @param $longitude
  3873. * @param $latitude
  3874. * @param $radius
  3875. * @param $unit
  3876. * @param array|null $options
  3877. * <pre>
  3878. * |Key |Value |Description |
  3879. * |------------|---------------|---------------------------------------------------|
  3880. * |COUNT |integer > 0 |Limit how many results are returned |
  3881. * | |WITHCOORD |Return longitude and latitude of matching members |
  3882. * | |WITHDIST |Return the distance from the center |
  3883. * | |WITHHASH |Return the raw geohash-encoded score |
  3884. * | |ASC |Sort results in ascending order |
  3885. * | |DESC |Sort results in descending order |
  3886. * |STORE |key |Store results in key |
  3887. * |STOREDIST |key |Store the results as distances in key |
  3888. * </pre>
  3889. * Note: It doesn't make sense to pass both ASC and DESC options but if both are passed
  3890. * the last one passed will be used.
  3891. * Note: When using STORE[DIST] in Redis Cluster, the store key must has to the same slot as
  3892. * the query key or you will get a CROSSLOT error.
  3893. * @return mixed When no STORE option is passed, this function returns an array of results.
  3894. * If it is passed this function returns the number of stored entries.
  3895. *
  3896. * @link https://redis.io/commands/georadius
  3897. * @since >= 3.2
  3898. * @example
  3899. * <pre>
  3900. * // Add some cities
  3901. * $redis->geoAdd("hawaii", -157.858, 21.306, "Honolulu", -156.331, 20.798, "Maui");
  3902. *
  3903. * echo "Within 300 miles of Honolulu:\n";
  3904. * var_dump($redis->geoRadius("hawaii", -157.858, 21.306, 300, 'mi'));
  3905. *
  3906. * echo "\nWithin 300 miles of Honolulu with distances:\n";
  3907. * $options = ['WITHDIST'];
  3908. * var_dump($redis->geoRadius("hawaii", -157.858, 21.306, 300, 'mi', $options));
  3909. *
  3910. * echo "\nFirst result within 300 miles of Honolulu with distances:\n";
  3911. * $options['count'] = 1;
  3912. * var_dump($redis->geoRadius("hawaii", -157.858, 21.306, 300, 'mi', $options));
  3913. *
  3914. * echo "\nFirst result within 300 miles of Honolulu with distances in descending sort order:\n";
  3915. * $options[] = 'DESC';
  3916. * var_dump($redis->geoRadius("hawaii", -157.858, 21.306, 300, 'mi', $options));
  3917. *
  3918. * // Output
  3919. * Within 300 miles of Honolulu:
  3920. * array(2) {
  3921. * [0]=> string(8) "Honolulu"
  3922. * [1]=> string(4) "Maui"
  3923. * }
  3924. *
  3925. * Within 300 miles of Honolulu with distances:
  3926. * array(2) {
  3927. * [0]=>
  3928. * array(2) {
  3929. * [0]=>
  3930. * string(8) "Honolulu"
  3931. * [1]=>
  3932. * string(6) "0.0002"
  3933. * }
  3934. * [1]=>
  3935. * array(2) {
  3936. * [0]=>
  3937. * string(4) "Maui"
  3938. * [1]=>
  3939. * string(8) "104.5615"
  3940. * }
  3941. * }
  3942. *
  3943. * First result within 300 miles of Honolulu with distances:
  3944. * array(1) {
  3945. * [0]=>
  3946. * array(2) {
  3947. * [0]=>
  3948. * string(8) "Honolulu"
  3949. * [1]=>
  3950. * string(6) "0.0002"
  3951. * }
  3952. * }
  3953. *
  3954. * First result within 300 miles of Honolulu with distances in descending sort order:
  3955. * array(1) {
  3956. * [0]=>
  3957. * array(2) {
  3958. * [0]=>
  3959. * string(4) "Maui"
  3960. * [1]=>
  3961. * string(8) "104.5615"
  3962. * }
  3963. * }
  3964. * </pre>
  3965. */
  3966. public function georadius($key, $longitude, $latitude, $radius, $unit, array $options = null)
  3967. {
  3968. }
  3969. /**
  3970. * This method is identical to geoRadius except that instead of passing a longitude and latitude as the "source"
  3971. * you pass an existing member in the geospatial set
  3972. *
  3973. * @param string $key
  3974. * @param string $member
  3975. * @param $radius
  3976. * @param $units
  3977. * @param array|null $options see georadius
  3978. *
  3979. * @return array The zero or more entries that are close enough to the member given the distance and radius specified
  3980. *
  3981. * @link https://redis.io/commands/georadiusbymember
  3982. * @since >= 3.2
  3983. * @see georadius
  3984. * @example
  3985. * <pre>
  3986. * $redis->geoAdd("hawaii", -157.858, 21.306, "Honolulu", -156.331, 20.798, "Maui");
  3987. *
  3988. * echo "Within 300 miles of Honolulu:\n";
  3989. * var_dump($redis->geoRadiusByMember("hawaii", "Honolulu", 300, 'mi'));
  3990. *
  3991. * echo "\nFirst match within 300 miles of Honolulu:\n";
  3992. * var_dump($redis->geoRadiusByMember("hawaii", "Honolulu", 300, 'mi', ['count' => 1]));
  3993. *
  3994. * // Output
  3995. * Within 300 miles of Honolulu:
  3996. * array(2) {
  3997. * [0]=> string(8) "Honolulu"
  3998. * [1]=> string(4) "Maui"
  3999. * }
  4000. *
  4001. * First match within 300 miles of Honolulu:
  4002. * array(1) {
  4003. * [0]=> string(8) "Honolulu"
  4004. * }
  4005. * </pre>
  4006. */
  4007. public function georadiusbymember($key, $member, $radius, $units, array $options = null)
  4008. {
  4009. }
  4010. /**
  4011. * Get or Set the redis config keys.
  4012. *
  4013. * @param string $operation either `GET` or `SET`
  4014. * @param string $key for `SET`, glob-pattern for `GET`
  4015. * @param string|mixed $value optional string (only for `SET`)
  4016. *
  4017. * @return array Associative array for `GET`, key -> value
  4018. *
  4019. * @link https://redis.io/commands/config-get
  4020. * @example
  4021. * <pre>
  4022. * $redis->config("GET", "*max-*-entries*");
  4023. * $redis->config("SET", "dir", "/var/run/redis/dumps/");
  4024. * </pre>
  4025. */
  4026. public function config($operation, $key, $value)
  4027. {
  4028. }
  4029. /**
  4030. * Evaluate a LUA script serverside
  4031. *
  4032. * @param string $script
  4033. * @param array $args
  4034. * @param int $numKeys
  4035. *
  4036. * @return mixed What is returned depends on what the LUA script itself returns, which could be a scalar value
  4037. * (int/string), or an array. Arrays that are returned can also contain other arrays, if that's how it was set up in
  4038. * your LUA script. If there is an error executing the LUA script, the getLastError() function can tell you the
  4039. * message that came back from Redis (e.g. compile error).
  4040. *
  4041. * @link https://redis.io/commands/eval
  4042. * @example
  4043. * <pre>
  4044. * $redis->eval("return 1"); // Returns an integer: 1
  4045. * $redis->eval("return {1,2,3}"); // Returns Array(1,2,3)
  4046. * $redis->del('mylist');
  4047. * $redis->rpush('mylist','a');
  4048. * $redis->rpush('mylist','b');
  4049. * $redis->rpush('mylist','c');
  4050. * // Nested response: Array(1,2,3,Array('a','b','c'));
  4051. * $redis->eval("return {1,2,3,redis.call('lrange','mylist',0,-1)}}");
  4052. * </pre>
  4053. */
  4054. public function eval($script, $args = array(), $numKeys = 0)
  4055. {
  4056. }
  4057. /**
  4058. * @see eval()
  4059. * @deprecated use Redis::eval()
  4060. *
  4061. * @param string $script
  4062. * @param array $args
  4063. * @param int $numKeys
  4064. * @return mixed @see eval()
  4065. */
  4066. public function evaluate($script, $args = array(), $numKeys = 0)
  4067. {
  4068. }
  4069. /**
  4070. * Evaluate a LUA script serverside, from the SHA1 hash of the script instead of the script itself.
  4071. * In order to run this command Redis will have to have already loaded the script, either by running it or via
  4072. * the SCRIPT LOAD command.
  4073. *
  4074. * @param string $scriptSha
  4075. * @param array $args
  4076. * @param int $numKeys
  4077. *
  4078. * @return mixed @see eval()
  4079. *
  4080. * @see eval()
  4081. * @link https://redis.io/commands/evalsha
  4082. * @example
  4083. * <pre>
  4084. * $script = 'return 1';
  4085. * $sha = $redis->script('load', $script);
  4086. * $redis->evalSha($sha); // Returns 1
  4087. * </pre>
  4088. */
  4089. public function evalSha($scriptSha, $args = array(), $numKeys = 0)
  4090. {
  4091. }
  4092. /**
  4093. * @see evalSha()
  4094. * @deprecated use Redis::evalSha()
  4095. *
  4096. * @param string $scriptSha
  4097. * @param array $args
  4098. * @param int $numKeys
  4099. */
  4100. public function evaluateSha($scriptSha, $args = array(), $numKeys = 0)
  4101. {
  4102. }
  4103. /**
  4104. * Execute the Redis SCRIPT command to perform various operations on the scripting subsystem.
  4105. * @param string $command load | flush | kill | exists
  4106. * @param string $script
  4107. *
  4108. * @return mixed
  4109. *
  4110. * @link https://redis.io/commands/script-load
  4111. * @link https://redis.io/commands/script-kill
  4112. * @link https://redis.io/commands/script-flush
  4113. * @link https://redis.io/commands/script-exists
  4114. * @example
  4115. * <pre>
  4116. * $redis->script('load', $script);
  4117. * $redis->script('flush');
  4118. * $redis->script('kill');
  4119. * $redis->script('exists', $script1, [$script2, $script3, ...]);
  4120. * </pre>
  4121. *
  4122. * SCRIPT LOAD will return the SHA1 hash of the passed script on success, and FALSE on failure.
  4123. * SCRIPT FLUSH should always return TRUE
  4124. * SCRIPT KILL will return true if a script was able to be killed and false if not
  4125. * SCRIPT EXISTS will return an array with TRUE or FALSE for each passed script
  4126. */
  4127. public function script($command, $script)
  4128. {
  4129. }
  4130. /**
  4131. * The last error message (if any)
  4132. *
  4133. * @return string|null A string with the last returned script based error message, or NULL if there is no error
  4134. *
  4135. * @example
  4136. * <pre>
  4137. * $redis->eval('this-is-not-lua');
  4138. * $err = $redis->getLastError();
  4139. * // "ERR Error compiling script (new function): user_script:1: '=' expected near '-'"
  4140. * </pre>
  4141. */
  4142. public function getLastError()
  4143. {
  4144. }
  4145. /**
  4146. * Clear the last error message
  4147. *
  4148. * @return bool true
  4149. *
  4150. * @example
  4151. * <pre>
  4152. * $redis->set('x', 'a');
  4153. * $redis->incr('x');
  4154. * $err = $redis->getLastError();
  4155. * // "ERR value is not an integer or out of range"
  4156. * $redis->clearLastError();
  4157. * $err = $redis->getLastError();
  4158. * // NULL
  4159. * </pre>
  4160. */
  4161. public function clearLastError()
  4162. {
  4163. }
  4164. /**
  4165. * Issue the CLIENT command with various arguments.
  4166. * The Redis CLIENT command can be used in four ways:
  4167. * - CLIENT LIST
  4168. * - CLIENT GETNAME
  4169. * - CLIENT SETNAME [name]
  4170. * - CLIENT KILL [ip:port]
  4171. *
  4172. * @param string $command
  4173. * @param string $value
  4174. * @return mixed This will vary depending on which client command was executed:
  4175. * - CLIENT LIST will return an array of arrays with client information.
  4176. * - CLIENT GETNAME will return the client name or false if none has been set
  4177. * - CLIENT SETNAME will return true if it can be set and false if not
  4178. * - CLIENT KILL will return true if the client can be killed, and false if not
  4179. *
  4180. * Note: phpredis will attempt to reconnect so you can actually kill your own connection but may not notice losing it!
  4181. *
  4182. * @link https://redis.io/commands/client-list
  4183. * @link https://redis.io/commands/client-getname
  4184. * @link https://redis.io/commands/client-setname
  4185. * @link https://redis.io/commands/client-kill
  4186. *
  4187. * @example
  4188. * <pre>
  4189. * $redis->client('list'); // Get a list of clients
  4190. * $redis->client('getname'); // Get the name of the current connection
  4191. * $redis->client('setname', 'somename'); // Set the name of the current connection
  4192. * $redis->client('kill', <ip:port>); // Kill the process at ip:port
  4193. * </pre>
  4194. */
  4195. public function client($command, $value = '')
  4196. {
  4197. }
  4198. /**
  4199. * A utility method to prefix the value with the prefix setting for phpredis.
  4200. *
  4201. * @param mixed $value The value you wish to prefix
  4202. *
  4203. * @return string If a prefix is set up, the value now prefixed.
  4204. * If there is no prefix, the value will be returned unchanged.
  4205. *
  4206. * @example
  4207. * <pre>
  4208. * $redis->setOption(Redis::OPT_PREFIX, 'my-prefix:');
  4209. * $redis->_prefix('my-value'); // Will return 'my-prefix:my-value'
  4210. * </pre>
  4211. */
  4212. public function _prefix($value)
  4213. {
  4214. }
  4215. /**
  4216. * A utility method to unserialize data with whatever serializer is set up. If there is no serializer set, the
  4217. * value will be returned unchanged. If there is a serializer set up, and the data passed in is malformed, an
  4218. * exception will be thrown. This can be useful if phpredis is serializing values, and you return something from
  4219. * redis in a LUA script that is serialized.
  4220. *
  4221. * @param string $value The value to be unserialized
  4222. *
  4223. * @return mixed
  4224. * @example
  4225. * <pre>
  4226. * $redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_PHP);
  4227. * $redis->_unserialize('a:3:{i:0;i:1;i:1;i:2;i:2;i:3;}'); // Will return Array(1,2,3)
  4228. * </pre>
  4229. */
  4230. public function _unserialize($value)
  4231. {
  4232. }
  4233. /**
  4234. * A utility method to serialize values manually. This method allows you to serialize a value with whatever
  4235. * serializer is configured, manually. This can be useful for serialization/unserialization of data going in
  4236. * and out of EVAL commands as phpredis can't automatically do this itself. Note that if no serializer is
  4237. * set, phpredis will change Array values to 'Array', and Objects to 'Object'.
  4238. *
  4239. * @param mixed $value The value to be serialized.
  4240. *
  4241. * @return mixed
  4242. * @example
  4243. * <pre>
  4244. * $redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_NONE);
  4245. * $redis->_serialize("foo"); // returns "foo"
  4246. * $redis->_serialize(Array()); // Returns "Array"
  4247. * $redis->_serialize(new stdClass()); // Returns "Object"
  4248. *
  4249. * $redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_PHP);
  4250. * $redis->_serialize("foo"); // Returns 's:3:"foo";'
  4251. * </pre>
  4252. */
  4253. public function _serialize($value)
  4254. {
  4255. }
  4256. /**
  4257. * Dump a key out of a redis database, the value of which can later be passed into redis using the RESTORE command.
  4258. * The data that comes out of DUMP is a binary representation of the key as Redis stores it.
  4259. * @param string $key
  4260. *
  4261. * @return string|bool The Redis encoded value of the key, or FALSE if the key doesn't exist
  4262. *
  4263. * @link https://redis.io/commands/dump
  4264. * @example
  4265. * <pre>
  4266. * $redis->set('foo', 'bar');
  4267. * $val = $redis->dump('foo'); // $val will be the Redis encoded key value
  4268. * </pre>
  4269. */
  4270. public function dump($key)
  4271. {
  4272. }
  4273. /**
  4274. * Restore a key from the result of a DUMP operation.
  4275. *
  4276. * @param string $key The key name
  4277. * @param int $ttl How long the key should live (if zero, no expire will be set on the key)
  4278. * @param string $value (binary). The Redis encoded key value (from DUMP)
  4279. *
  4280. * @return bool
  4281. *
  4282. * @link https://redis.io/commands/restore
  4283. * @example
  4284. * <pre>
  4285. * $redis->set('foo', 'bar');
  4286. * $val = $redis->dump('foo');
  4287. * $redis->restore('bar', 0, $val); // The key 'bar', will now be equal to the key 'foo'
  4288. * </pre>
  4289. */
  4290. public function restore($key, $ttl, $value)
  4291. {
  4292. }
  4293. /**
  4294. * Migrates a key to a different Redis instance.
  4295. *
  4296. * @param string $host The destination host
  4297. * @param int $port The TCP port to connect to.
  4298. * @param string $key The key to migrate.
  4299. * @param int $db The target DB.
  4300. * @param int $timeout The maximum amount of time given to this transfer.
  4301. * @param bool $copy Should we send the COPY flag to redis.
  4302. * @param bool $replace Should we send the REPLACE flag to redis.
  4303. *
  4304. * @return bool
  4305. *
  4306. * @link https://redis.io/commands/migrate
  4307. * @example
  4308. * <pre>
  4309. * $redis->migrate('backup', 6379, 'foo', 0, 3600);
  4310. * </pre>
  4311. */
  4312. public function migrate($host, $port, $key, $db, $timeout, $copy = false, $replace = false)
  4313. {
  4314. }
  4315. /**
  4316. * Return the current Redis server time.
  4317. *
  4318. * @return array If successfull, the time will come back as an associative array with element zero being the
  4319. * unix timestamp, and element one being microseconds.
  4320. *
  4321. * @link https://redis.io/commands/time
  4322. * @example
  4323. * <pre>
  4324. * var_dump( $redis->time() );
  4325. * // array(2) {
  4326. * // [0] => string(10) "1342364352"
  4327. * // [1] => string(6) "253002"
  4328. * // }
  4329. * </pre>
  4330. */
  4331. public function time()
  4332. {
  4333. }
  4334. /**
  4335. * Scan the keyspace for keys
  4336. *
  4337. * @param int $iterator Iterator, initialized to NULL.
  4338. * @param string $pattern Pattern to match.
  4339. * @param int $count Count of keys per iteration (only a suggestion to Redis).
  4340. *
  4341. * @return array|bool This function will return an array of keys or FALSE if there are no more keys.
  4342. *
  4343. * @link https://redis.io/commands/scan
  4344. * @example
  4345. * <pre>
  4346. * $iterator = null;
  4347. * while(false !== ($keys = $redis->scan($iterator))) {
  4348. * foreach($keys as $key) {
  4349. * echo $key . PHP_EOL;
  4350. * }
  4351. * }
  4352. * </pre>
  4353. */
  4354. public function scan(&$iterator, $pattern = null, $count = 0)
  4355. {
  4356. }
  4357. /**
  4358. * Adds all the element arguments to the HyperLogLog data structure stored at the key.
  4359. *
  4360. * @param string $key
  4361. * @param array $elements
  4362. *
  4363. * @return bool
  4364. *
  4365. * @link https://redis.io/commands/pfadd
  4366. * @example $redis->pfAdd('key', array('elem1', 'elem2'))
  4367. */
  4368. public function pfAdd($key, array $elements)
  4369. {
  4370. }
  4371. /**
  4372. * When called with a single key, returns the approximated cardinality computed by the HyperLogLog data
  4373. * structure stored at the specified variable, which is 0 if the variable does not exist.
  4374. *
  4375. * @param string|array $key
  4376. *
  4377. * @return int
  4378. *
  4379. * @link https://redis.io/commands/pfcount
  4380. * @example
  4381. * <pre>
  4382. * $redis->pfAdd('key1', array('elem1', 'elem2'));
  4383. * $redis->pfAdd('key2', array('elem3', 'elem2'));
  4384. * $redis->pfCount('key1'); // int(2)
  4385. * $redis->pfCount(array('key1', 'key2')); // int(3)
  4386. */
  4387. public function pfCount($key)
  4388. {
  4389. }
  4390. /**
  4391. * Merge multiple HyperLogLog values into an unique value that will approximate the cardinality
  4392. * of the union of the observed Sets of the source HyperLogLog structures.
  4393. *
  4394. * @param string $destKey
  4395. * @param array $sourceKeys
  4396. *
  4397. * @return bool
  4398. *
  4399. * @link https://redis.io/commands/pfmerge
  4400. * @example
  4401. * <pre>
  4402. * $redis->pfAdd('key1', array('elem1', 'elem2'));
  4403. * $redis->pfAdd('key2', array('elem3', 'elem2'));
  4404. * $redis->pfMerge('key3', array('key1', 'key2'));
  4405. * $redis->pfCount('key3'); // int(3)
  4406. */
  4407. public function pfMerge($destKey, array $sourceKeys)
  4408. {
  4409. }
  4410. /**
  4411. * Send arbitrary things to the redis server.
  4412. *
  4413. * @param string $command Required command to send to the server.
  4414. * @param mixed $arguments Optional variable amount of arguments to send to the server.
  4415. *
  4416. * @return mixed
  4417. *
  4418. * @example
  4419. * <pre>
  4420. * $redis->rawCommand('SET', 'key', 'value'); // bool(true)
  4421. * $redis->rawCommand('GET", 'key'); // string(5) "value"
  4422. * </pre>
  4423. */
  4424. public function rawCommand($command, $arguments)
  4425. {
  4426. }
  4427. /**
  4428. * Detect whether we're in ATOMIC/MULTI/PIPELINE mode.
  4429. *
  4430. * @return int Either Redis::ATOMIC, Redis::MULTI or Redis::PIPELINE
  4431. *
  4432. * @example $redis->getMode();
  4433. */
  4434. public function getMode()
  4435. {
  4436. }
  4437. /**
  4438. * Acknowledge one or more messages on behalf of a consumer group.
  4439. *
  4440. * @param string $stream
  4441. * @param string $group
  4442. * @param array $messages
  4443. *
  4444. * @return int The number of messages Redis reports as acknowledged.
  4445. *
  4446. * @link https://redis.io/commands/xack
  4447. * @example
  4448. * <pre>
  4449. * $redis->xAck('stream', 'group1', ['1530063064286-0', '1530063064286-1']);
  4450. * </pre>
  4451. */
  4452. public function xAck($stream, $group, $messages)
  4453. {
  4454. }
  4455. /**
  4456. * Add a message to a stream
  4457. *
  4458. * @param string $key
  4459. * @param string $id
  4460. * @param array $messages
  4461. * @param int $maxLen
  4462. * @param bool $isApproximate
  4463. *
  4464. * @return string The added message ID.
  4465. *
  4466. * @link https://redis.io/commands/xadd
  4467. * @example
  4468. * <pre>
  4469. * $redis->xAdd('mystream', "*", ['field' => 'value']);
  4470. * $redis->xAdd('mystream', "*", ['field' => 'value'], 10);
  4471. * $redis->xAdd('mystream', "*", ['field' => 'value'], 10, true);
  4472. * </pre>
  4473. */
  4474. public function xAdd($key, $id, $messages, $maxLen = 0, $isApproximate = false)
  4475. {
  4476. }
  4477. /**
  4478. * Claim ownership of one or more pending messages
  4479. *
  4480. * @param string $key
  4481. * @param string $group
  4482. * @param string $consumer
  4483. * @param int $minIdleTime
  4484. * @param array $ids
  4485. * @param array $options ['IDLE' => $value, 'TIME' => $value, 'RETRYCOUNT' => $value, 'FORCE', 'JUSTID']
  4486. *
  4487. * @return array Either an array of message IDs along with corresponding data, or just an array of IDs
  4488. * (if the 'JUSTID' option was passed).
  4489. *
  4490. * @link https://redis.io/commands/xclaim
  4491. * @example
  4492. * <pre>
  4493. * $ids = ['1530113681011-0', '1530113681011-1', '1530113681011-2'];
  4494. *
  4495. * // Without any options
  4496. * $redis->xClaim('mystream', 'group1', 'myconsumer1', 0, $ids);
  4497. *
  4498. * // With options
  4499. * $redis->xClaim(
  4500. * 'mystream', 'group1', 'myconsumer2', 0, $ids,
  4501. * [
  4502. * 'IDLE' => time() * 1000,
  4503. * 'RETRYCOUNT' => 5,
  4504. * 'FORCE',
  4505. * 'JUSTID'
  4506. * ]
  4507. * );
  4508. * </pre>
  4509. */
  4510. public function xClaim($key, $group, $consumer, $minIdleTime, $ids, $options = [])
  4511. {
  4512. }
  4513. /**
  4514. * Delete one or more messages from a stream
  4515. *
  4516. * @param string $key
  4517. * @param array $ids
  4518. *
  4519. * @return int The number of messages removed
  4520. *
  4521. * @link https://redis.io/commands/xdel
  4522. * @example
  4523. * <pre>
  4524. * $redis->xDel('mystream', ['1530115304877-0', '1530115305731-0']);
  4525. * </pre>
  4526. */
  4527. public function xDel($key, $ids)
  4528. {
  4529. }
  4530. /**
  4531. * @param string $operation e.g.: 'HELP', 'SETID', 'DELGROUP', 'CREATE', 'DELCONSUMER'
  4532. * @param string $key
  4533. * @param string $group
  4534. * @param string $msgId
  4535. * @param bool $mkStream
  4536. *
  4537. * @return mixed This command returns different types depending on the specific XGROUP command executed.
  4538. *
  4539. * @link https://redis.io/commands/xgroup
  4540. * @example
  4541. * <pre>
  4542. * $redis->xGroup('CREATE', 'mystream', 'mygroup', 0);
  4543. * $redis->xGroup('CREATE', 'mystream', 'mygroup', 0, true); // create stream
  4544. * $redis->xGroup('DESTROY', 'mystream', 'mygroup');
  4545. * </pre>
  4546. */
  4547. public function xGroup($operation, $key, $group, $msgId = '', $mkStream = false)
  4548. {
  4549. }
  4550. /**
  4551. * Get information about a stream or consumer groups
  4552. *
  4553. * @param string $operation e.g.: 'CONSUMERS', 'GROUPS', 'STREAM', 'HELP'
  4554. * @param string $stream
  4555. * @param string $group
  4556. *
  4557. * @return mixed This command returns different types depending on which subcommand is used.
  4558. *
  4559. * @link https://redis.io/commands/xinfo
  4560. * @example
  4561. * <pre>
  4562. * $redis->xInfo('STREAM', 'mystream');
  4563. * </pre>
  4564. */
  4565. public function xInfo($operation, $stream, $group)
  4566. {
  4567. }
  4568. /**
  4569. * Get the length of a given stream.
  4570. *
  4571. * @param string $stream
  4572. *
  4573. * @return int The number of messages in the stream.
  4574. *
  4575. * @link https://redis.io/commands/xlen
  4576. * @example
  4577. * <pre>
  4578. * $redis->xLen('mystream');
  4579. * </pre>
  4580. */
  4581. public function xLen($stream)
  4582. {
  4583. }
  4584. /**
  4585. * Get information about pending messages in a given stream
  4586. *
  4587. * @param string $stream
  4588. * @param string $group
  4589. * @param string $start
  4590. * @param string $end
  4591. * @param int $count
  4592. * @param string $consumer
  4593. *
  4594. * @return array Information about the pending messages, in various forms depending on
  4595. * the specific invocation of XPENDING.
  4596. *
  4597. * @link https://redis.io/commands/xpending
  4598. * @example
  4599. * <pre>
  4600. * $redis->xPending('mystream', 'mygroup');
  4601. * $redis->xPending('mystream', 'mygroup', '-', '+', 1, 'consumer-1');
  4602. * </pre>
  4603. */
  4604. public function xPending($stream, $group, $start = null, $end = null, $count = null, $consumer = null)
  4605. {
  4606. }
  4607. /**
  4608. * Get a range of messages from a given stream
  4609. *
  4610. * @param string $stream
  4611. * @param string $start
  4612. * @param string $end
  4613. * @param int $count
  4614. *
  4615. * @return array The messages in the stream within the requested range.
  4616. *
  4617. * @link https://redis.io/commands/xrange
  4618. * @example
  4619. * <pre>
  4620. * // Get everything in this stream
  4621. * $redis->xRange('mystream', '-', '+');
  4622. * // Only the first two messages
  4623. * $redis->xRange('mystream', '-', '+', 2);
  4624. * </pre>
  4625. */
  4626. public function xRange($stream, $start, $end, $count = null)
  4627. {
  4628. }
  4629. /**
  4630. * Read data from one or more streams and only return IDs greater than sent in the command.
  4631. *
  4632. * @param array $streams
  4633. * @param int|string $count
  4634. * @param int|string $block
  4635. *
  4636. * @return array The messages in the stream newer than the IDs passed to Redis (if any)
  4637. *
  4638. * @link https://redis.io/commands/xread
  4639. * @example
  4640. * <pre>
  4641. * $redis->xRead(['stream1' => '1535222584555-0', 'stream2' => '1535222584555-0']);
  4642. * </pre>
  4643. */
  4644. public function xRead($streams, $count = null, $block = null)
  4645. {
  4646. }
  4647. /**
  4648. * This method is similar to xRead except that it supports reading messages for a specific consumer group.
  4649. *
  4650. * @param string $group
  4651. * @param string $consumer
  4652. * @param array $streams
  4653. * @param int|null $count
  4654. * @param int|null $block
  4655. *
  4656. * @return array The messages delivered to this consumer group (if any).
  4657. *
  4658. * @link https://redis.io/commands/xreadgroup
  4659. * @example
  4660. * <pre>
  4661. * // Consume messages for 'mygroup', 'consumer1'
  4662. * $redis->xReadGroup('mygroup', 'consumer1', ['s1' => 0, 's2' => 0]);
  4663. * // Read a single message as 'consumer2' for up to a second until a message arrives.
  4664. * $redis->xReadGroup('mygroup', 'consumer2', ['s1' => 0, 's2' => 0], 1, 1000);
  4665. * </pre>
  4666. */
  4667. public function xReadGroup($group, $consumer, $streams, $count = null, $block = null)
  4668. {
  4669. }
  4670. /**
  4671. * This is identical to xRange except the results come back in reverse order.
  4672. * Also note that Redis reverses the order of "start" and "end".
  4673. *
  4674. * @param string $stream
  4675. * @param string $end
  4676. * @param string $start
  4677. * @param int $count
  4678. *
  4679. * @return array The messages in the range specified
  4680. *
  4681. * @link https://redis.io/commands/xrevrange
  4682. * @example
  4683. * <pre>
  4684. * $redis->xRevRange('mystream', '+', '-');
  4685. * </pre>
  4686. */
  4687. public function xRevRange($stream, $end, $start, $count = null)
  4688. {
  4689. }
  4690. /**
  4691. * Trim the stream length to a given maximum.
  4692. * If the "approximate" flag is pasesed, Redis will use your size as a hint but only trim trees in whole nodes
  4693. * (this is more efficient)
  4694. *
  4695. * @param string $stream
  4696. * @param int $maxLen
  4697. * @param bool $isApproximate
  4698. *
  4699. * @return int The number of messages trimed from the stream.
  4700. *
  4701. * @link https://redis.io/commands/xtrim
  4702. * @example
  4703. * <pre>
  4704. * // Trim to exactly 100 messages
  4705. * $redis->xTrim('mystream', 100);
  4706. * // Let Redis approximate the trimming
  4707. * $redis->xTrim('mystream', 100, true);
  4708. * </pre>
  4709. */
  4710. public function xTrim($stream, $maxLen, $isApproximate)
  4711. {
  4712. }
  4713. /**
  4714. * Adds a values to the set value stored at key.
  4715. *
  4716. * @param string $key Required key
  4717. * @param array $values Required values
  4718. *
  4719. * @return int|bool The number of elements added to the set.
  4720. * If this value is already in the set, FALSE is returned
  4721. *
  4722. * @link https://redis.io/commands/sadd
  4723. * @link https://github.com/phpredis/phpredis/commit/3491b188e0022f75b938738f7542603c7aae9077
  4724. * @since phpredis 2.2.8
  4725. * @example
  4726. * <pre>
  4727. * $redis->sAddArray('k', array('v1')); // boolean
  4728. * $redis->sAddArray('k', array('v1', 'v2', 'v3')); // boolean
  4729. * </pre>
  4730. */
  4731. public function sAddArray($key, array $values)
  4732. {
  4733. }
  4734. }
  4735. class RedisException extends Exception
  4736. {
  4737. }
  4738. /**
  4739. * @mixin \Redis
  4740. */
  4741. class RedisArray
  4742. {
  4743. /**
  4744. * Constructor
  4745. *
  4746. * @param string|array $hosts Name of the redis array from redis.ini or array of hosts to construct the array with
  4747. * @param array $opts Array of options
  4748. *
  4749. * @link https://github.com/nicolasff/phpredis/blob/master/arrays.markdown
  4750. */
  4751. public function __construct($hosts, array $opts = null)
  4752. {
  4753. }
  4754. /**
  4755. * @return array list of hosts for the selected array
  4756. */
  4757. public function _hosts()
  4758. {
  4759. }
  4760. /**
  4761. * @return string the name of the function used to extract key parts during consistent hashing
  4762. */
  4763. public function _function()
  4764. {
  4765. }
  4766. /**
  4767. * @param string $key The key for which you want to lookup the host
  4768. *
  4769. * @return string the host to be used for a certain key
  4770. */
  4771. public function _target($key)
  4772. {
  4773. }
  4774. /**
  4775. * Use this function when a new node is added and keys need to be rehashed.
  4776. */
  4777. public function _rehash()
  4778. {
  4779. }
  4780. /**
  4781. * Returns an associative array of strings and integers, with the following keys:
  4782. * - redis_version
  4783. * - redis_git_sha1
  4784. * - redis_git_dirty
  4785. * - redis_build_id
  4786. * - redis_mode
  4787. * - os
  4788. * - arch_bits
  4789. * - multiplexing_api
  4790. * - atomicvar_api
  4791. * - gcc_version
  4792. * - process_id
  4793. * - run_id
  4794. * - tcp_port
  4795. * - uptime_in_seconds
  4796. * - uptime_in_days
  4797. * - hz
  4798. * - lru_clock
  4799. * - executable
  4800. * - config_file
  4801. * - connected_clients
  4802. * - client_longest_output_list
  4803. * - client_biggest_input_buf
  4804. * - blocked_clients
  4805. * - used_memory
  4806. * - used_memory_human
  4807. * - used_memory_rss
  4808. * - used_memory_rss_human
  4809. * - used_memory_peak
  4810. * - used_memory_peak_human
  4811. * - used_memory_peak_perc
  4812. * - used_memory_peak
  4813. * - used_memory_overhead
  4814. * - used_memory_startup
  4815. * - used_memory_dataset
  4816. * - used_memory_dataset_perc
  4817. * - total_system_memory
  4818. * - total_system_memory_human
  4819. * - used_memory_lua
  4820. * - used_memory_lua_human
  4821. * - maxmemory
  4822. * - maxmemory_human
  4823. * - maxmemory_policy
  4824. * - mem_fragmentation_ratio
  4825. * - mem_allocator
  4826. * - active_defrag_running
  4827. * - lazyfree_pending_objects
  4828. * - mem_fragmentation_ratio
  4829. * - loading
  4830. * - rdb_changes_since_last_save
  4831. * - rdb_bgsave_in_progress
  4832. * - rdb_last_save_time
  4833. * - rdb_last_bgsave_status
  4834. * - rdb_last_bgsave_time_sec
  4835. * - rdb_current_bgsave_time_sec
  4836. * - rdb_last_cow_size
  4837. * - aof_enabled
  4838. * - aof_rewrite_in_progress
  4839. * - aof_rewrite_scheduled
  4840. * - aof_last_rewrite_time_sec
  4841. * - aof_current_rewrite_time_sec
  4842. * - aof_last_bgrewrite_status
  4843. * - aof_last_write_status
  4844. * - aof_last_cow_size
  4845. * - changes_since_last_save
  4846. * - aof_current_size
  4847. * - aof_base_size
  4848. * - aof_pending_rewrite
  4849. * - aof_buffer_length
  4850. * - aof_rewrite_buffer_length
  4851. * - aof_pending_bio_fsync
  4852. * - aof_delayed_fsync
  4853. * - loading_start_time
  4854. * - loading_total_bytes
  4855. * - loading_loaded_bytes
  4856. * - loading_loaded_perc
  4857. * - loading_eta_seconds
  4858. * - total_connections_received
  4859. * - total_commands_processed
  4860. * - instantaneous_ops_per_sec
  4861. * - total_net_input_bytes
  4862. * - total_net_output_bytes
  4863. * - instantaneous_input_kbps
  4864. * - instantaneous_output_kbps
  4865. * - rejected_connections
  4866. * - maxclients
  4867. * - sync_full
  4868. * - sync_partial_ok
  4869. * - sync_partial_err
  4870. * - expired_keys
  4871. * - evicted_keys
  4872. * - keyspace_hits
  4873. * - keyspace_misses
  4874. * - pubsub_channels
  4875. * - pubsub_patterns
  4876. * - latest_fork_usec
  4877. * - migrate_cached_sockets
  4878. * - slave_expires_tracked_keys
  4879. * - active_defrag_hits
  4880. * - active_defrag_misses
  4881. * - active_defrag_key_hits
  4882. * - active_defrag_key_misses
  4883. * - role
  4884. * - master_replid
  4885. * - master_replid2
  4886. * - master_repl_offset
  4887. * - second_repl_offset
  4888. * - repl_backlog_active
  4889. * - repl_backlog_size
  4890. * - repl_backlog_first_byte_offset
  4891. * - repl_backlog_histlen
  4892. * - master_host
  4893. * - master_port
  4894. * - master_link_status
  4895. * - master_last_io_seconds_ago
  4896. * - master_sync_in_progress
  4897. * - slave_repl_offset
  4898. * - slave_priority
  4899. * - slave_read_only
  4900. * - master_sync_left_bytes
  4901. * - master_sync_last_io_seconds_ago
  4902. * - master_link_down_since_seconds
  4903. * - connected_slaves
  4904. * - min-slaves-to-write
  4905. * - min-replicas-to-write
  4906. * - min_slaves_good_slaves
  4907. * - used_cpu_sys
  4908. * - used_cpu_user
  4909. * - used_cpu_sys_children
  4910. * - used_cpu_user_children
  4911. * - cluster_enabled
  4912. *
  4913. * @link https://redis.io/commands/info
  4914. * @return array
  4915. * @example
  4916. * <pre>
  4917. * $redis->info();
  4918. * </pre>
  4919. */
  4920. public function info() {
  4921. }
  4922. }