Skip to content

Commit 9ed9fb1

Browse files
author
Max Kamashev
committed
add few commands
1 parent 73ab81a commit 9ed9fb1

File tree

1 file changed

+203
-0
lines changed

1 file changed

+203
-0
lines changed

redisphp.php

Lines changed: 203 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,209 @@ public function subscribe($channels, $callback) {}
242242
*/
243243
public function publish($channel, $message) {}
244244

245+
/**
246+
* Verify if the specified key exists.
247+
*
248+
* @param string $key
249+
* @return BOOL: If the key exists, return TRUE, otherwise return FALSE.
250+
* @example
251+
* $redis->set('key', 'value');
252+
* $redis->exists('key'); // TRUE
253+
* $redis->exists('NonExistingKey'); // FALSE
254+
*/
255+
public function exists($key) {}
256+
257+
/**
258+
* Increment the number stored at key by one.
259+
*
260+
* @param type $key
261+
* @return INT the new value
262+
* @example
263+
* $redis->incr('key1'); // key1 didn't exists, set to 0 before the increment and now has the value 1
264+
* $redis->incr('key1'); // 2
265+
* $redis->incr('key1'); // 3
266+
* $redis->incr('key1'); // 4
267+
*/
268+
public function incr($key) {}
269+
270+
/**
271+
* Increment the number stored at key by one. If the second argument is filled, it will be used as the integer value of the increment.
272+
*
273+
* @param string $key key
274+
* @param int $value value that will be added to key (only for incrBy)
275+
* @return INT the new value
276+
* @example
277+
* $redis->incr('key1'); // key1 didn't exists, set to 0 before the increment and now has the value 1
278+
* $redis->incr('key1'); // 2
279+
* $redis->incr('key1'); // 3
280+
* $redis->incr('key1'); // 4
281+
* $redis->incrBy('key1', 10); // 14
282+
*/
283+
public function incrBy($key, $value) {}
284+
285+
/**
286+
* Decrement the number stored at key by one.
287+
*
288+
* @param string $key
289+
* @return INT the new value
290+
* @example
291+
* $redis->decr('key1'); // key1 didn't exists, set to 0 before the increment and now has the value -1
292+
* $redis->decr('key1'); // -2
293+
* $redis->decr('key1'); // -3
294+
*/
295+
public function decr($key) {}
296+
297+
/**
298+
* Decrement the number stored at key by one. If the second argument is filled, it will be used as the integer value of the decrement.
299+
*
300+
* @param string $key
301+
* @param int $value that will be substracted to key (only for decrBy)
302+
* @return INT the new value
303+
* @example
304+
* $redis->decr('key1'); // key1 didn't exists, set to 0 before the increment and now has the value -1
305+
* $redis->decr('key1'); // -2
306+
* $redis->decr('key1'); // -3
307+
* $redis->decrBy('key1', 10); // -13
308+
*/
309+
public function decrBy($key, $value) {}
310+
311+
/**
312+
* Get the values of all the specified keys. If one or more keys dont exist, the array will contain FALSE at the position of the key.
313+
*
314+
* @param array $keys Array containing the list of the keys
315+
* @return Array: Array containing the values related to keys in argument
316+
* @example
317+
* $redis->set('key1', 'value1');
318+
* $redis->set('key2', 'value2');
319+
* $redis->set('key3', 'value3');
320+
* $redis->getMultiple(array('key1', 'key2', 'key3')); // array('value1', 'value2', 'value3');
321+
* $redis->getMultiple(array('key0', 'key1', 'key5')); // array(`FALSE`, 'value2', `FALSE`);
322+
*/
323+
public function getMultiple(array $keys) {}
324+
325+
/**
326+
* Adds the string value to the head (left) of the list. Creates the list if the key didn't exist. If the key exists and is not a list, FALSE is returned.
327+
*
328+
* @param string $key
329+
* @param string $value String, value to push in key
330+
* @return LONG The new length of the list in case of success, FALSE in case of Failure.
331+
* @example
332+
* $redis->delete('key1');
333+
* $redis->lPush('key1', 'C'); // returns 1
334+
* $redis->lPush('key1', 'B'); // returns 2
335+
* $redis->lPush('key1', 'A'); // returns 3
336+
* // key1 now points to the following list: [ 'A', 'B', 'C' ]
337+
*/
338+
public function lPush($key, $value) {}
339+
340+
/**
341+
* Adds the string value to the tail (right) of the list. Creates the list if the key didn't exist. If the key exists and is not a list, FALSE is returned.
342+
*
343+
* @param string $key
344+
* @param string $value String, value to push in key
345+
* @return LONG The new length of the list in case of success, FALSE in case of Failure.
346+
* @example
347+
* $redis->delete('key1');
348+
* $redis->rPush('key1', 'A'); // returns 1
349+
* $redis->rPush('key1', 'B'); // returns 2
350+
* $redis->rPush('key1', 'C'); // returns 3
351+
* // key1 now points to the following list: [ 'A', 'B', 'C' ]
352+
*/
353+
public function rPush($key, $value) {}
354+
355+
/**
356+
* Adds the string value to the head (left) of the list if the list exists.
357+
*
358+
* @param type $key
359+
* @param type $value String, value to push in key
360+
* @return LONG The new length of the list in case of success, FALSE in case of Failure.
361+
* @example
362+
* $redis->delete('key1');
363+
* $redis->lPushx('key1', 'A'); // returns 0
364+
* $redis->lPush('key1', 'A'); // returns 1
365+
* $redis->lPushx('key1', 'B'); // returns 2
366+
* $redis->lPushx('key1', 'C'); // returns 3
367+
* // key1 now points to the following list: [ 'A', 'B', 'C' ]
368+
*/
369+
public function lPushx($key, $value) {}
370+
371+
/**
372+
* Adds the string value to the tail (right) of the list if the ist exists. FALSE in case of Failure.
373+
*
374+
* @param string $key
375+
* @param string $value String, value to push in key
376+
* @return LONG The new length of the list in case of success, FALSE in case of Failure.
377+
* @example
378+
* $redis->delete('key1');
379+
* $redis->rPushx('key1', 'A'); // returns 0
380+
* $redis->rPush('key1', 'A'); // returns 1
381+
* $redis->rPushx('key1', 'B'); // returns 2
382+
* $redis->rPushx('key1', 'C'); // returns 3
383+
* // key1 now points to the following list: [ 'A', 'B', 'C' ]
384+
*/
385+
public function rPushx($key, $value) {}
386+
387+
/**
388+
* Returns and removes the first element of the list.
389+
*
390+
* @param type $key
391+
* @return STRING if command executed successfully BOOL FALSE in case of failure (empty list)
392+
* @example
393+
* $redis->rPush('key1', 'A');
394+
* $redis->rPush('key1', 'B');
395+
* $redis->rPush('key1', 'C'); // key1 => [ 'A', 'B', 'C' ]
396+
* $redis->lPop('key1'); // key1 => [ 'B', 'C' ]
397+
*/
398+
public function lPop($key) {}
399+
400+
/**
401+
* Returns and removes the last element of the list.
402+
*
403+
* @param type $key
404+
* @return STRING if command executed successfully BOOL FALSE in case of failure (empty list)
405+
* @example
406+
* $redis->rPush('key1', 'A');
407+
* $redis->rPush('key1', 'B');
408+
* $redis->rPush('key1', 'C'); // key1 => [ 'A', 'B', 'C' ]
409+
* $redis->rPop('key1'); // key1 => [ 'A', 'B' ]
410+
*/
411+
public function rPop($key) {}
412+
413+
/**
414+
* Is a blocking lPop(rPop) primitive. If at least one of the lists contains at least one element, the element will be popped from the head of the list and returned to the caller. Il all the list identified by the keys passed in arguments are empty, blPop will block during the specified timeout until an element is pushed to one of those lists. This element will be popped.
415+
*
416+
* @param array $keys Array containing the keys of the lists INTEGER Timeout Or STRING Key1 STRING Key2 STRING Key3 ... STRING Keyn INTEGER Timeout
417+
* @return ARRAY array('listName', 'element')
418+
* @example
419+
* // Non blocking feature
420+
* $redis->lPush('key1', 'A');
421+
* $redis->delete('key2');
422+
*
423+
* $redis->blPop('key1', 'key2', 10); // array('key1', 'A')
424+
* // OR
425+
* $redis->blPop(array('key1', 'key2'), 10); // array('key1', 'A')
426+
*
427+
* $redis->brPop('key1', 'key2', 10); // array('key1', 'A')
428+
* // OR
429+
* $redis->brPop(array('key1', 'key2'), 10); // array('key1', 'A')
430+
*
431+
* // Blocking feature
432+
*
433+
* // process 1
434+
* $redis->delete('key1');
435+
* $redis->blPop('key1', 10);
436+
* // blocking for 10 seconds
437+
*
438+
* // process 2
439+
* $redis->lPush('key1', 'A');
440+
*
441+
* // process 1
442+
* // array('key1', 'A') is returned
443+
*/
444+
public function blPop(array $keys) {}
445+
446+
447+
245448

246449

247450

0 commit comments

Comments
 (0)