X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fobjectcache%2FHashBagOStuff.php;h=d061eff0ec09b1347d603ac1fbf757d0ee0a7604;hb=fd03fa28251c84b00c9d623d8b3461add7887904;hp=799f26a3f424b2aaad8918ec4801ebc6af3558e3;hpb=1677c02ff1549a629f7b9516b4308049b76f317b;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/objectcache/HashBagOStuff.php b/includes/objectcache/HashBagOStuff.php index 799f26a3f4..d061eff0ec 100644 --- a/includes/objectcache/HashBagOStuff.php +++ b/includes/objectcache/HashBagOStuff.php @@ -52,9 +52,10 @@ class HashBagOStuff extends BagOStuff { /** * @param $key string + * @param $casToken[optional] mixed * @return bool|mixed */ - function get( $key ) { + function get( $key, &$casToken = null ) { if ( !isset( $this->bag[$key] ) ) { return false; } @@ -63,6 +64,8 @@ class HashBagOStuff extends BagOStuff { return false; } + $casToken = $this->bag[$key][0]; + return $this->bag[$key][0]; } @@ -77,6 +80,21 @@ class HashBagOStuff extends BagOStuff { return true; } + /** + * @param $casToken mixed + * @param $key string + * @param $value mixed + * @param $exptime int + * @return bool + */ + function cas( $casToken, $key, $value, $exptime = 0 ) { + if ( $this->get( $key ) === $casToken ) { + return $this->set( $key, $value, $exptime ); + } + + return false; + } + /** * @param $key string * @param $time int @@ -91,12 +109,4 @@ class HashBagOStuff extends BagOStuff { return true; } - - /** - * @return array - */ - function keys() { - return array_keys( $this->bag ); - } } -