getSet 命令/方法/函数

Description

Sets a value and returns the previous entry at that key.

设置一个VALUE 并且返回该KEY当前的VALUE。


Parameters

Key: key


STRING: value


Return value

A string, the previous value located at this key.


Example

$redis->set('x', '42');

$exValue = $redis->getSet('x', 'lol');  // return '42', replaces x by 'lol'

$newValue = $redis->get('x')'       // return 'lol'