Skip to content

Commit bcd3f76

Browse files
committed
fixed #25 - add options in set() signature
1 parent 875e730 commit bcd3f76

File tree

1 file changed

+24
-7
lines changed

1 file changed

+24
-7
lines changed

src/Redis.php

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -210,14 +210,31 @@ public function get( $key ) {}
210210
/**
211211
* Set the string value in argument as value of the key.
212212
*
213-
* @param string $key
214-
* @param string $value
215-
* @param int $ttl Calling setex() is preferred if you want a Time To Live.
216-
* @return bool: If the command is successful return TRUE or 'Redis Socket Buffer' object
217-
* @link http://redis.io/commands/set
218-
* @example $redis->set('key', 'value');
213+
* @since If you're using Redis >= 2.6.12, you can pass extended options as explained in example
214+
*
215+
* @param string $key
216+
* @param string $value
217+
* @param int|array $timeout If you pass an integer, phpredis will redirect to SETEX, and will try to use Redis >= 2.6.12 extended options if you pass an array with valid values
218+
*
219+
* <pre>
220+
* // Simple key -> value set
221+
* $redis->set('key', 'value');
222+
*
223+
* // Will redirect, and actually make an SETEX call
224+
* $redis->set('key','value', 10);
225+
*
226+
* // Will set the key, if it doesn't exist, with a ttl of 10 seconds
227+
* $redis->set('key', 'value', Array('nx', 'ex'=>10));
228+
*
229+
* // Will set a key, if it does exist, with a ttl of 1000 miliseconds
230+
* $redis->set('key', 'value', Array('xx', 'px'=>1000));
231+
* </pre>
232+
*
233+
* @return bool TRUE if the command is successful.
234+
*
235+
* @link http://redis.io/commands/set
219236
*/
220-
public function set( $key, $value, $ttl = 0 ) {}
237+
public function set( $key, $value, $timeout = 0 ) {}
221238

222239
/**
223240
* Set the string value in argument as value of the key, with a time to live.

0 commit comments

Comments
 (0)