32 $params[
'segmentationSize'] = $params[
'segmentationSize'] ?? INF;
33 parent::__construct( $params );
36 protected function doGet( $key, $flags = 0, &$casToken =
null ) {
39 $blob = wincache_ucache_get( $key );
40 if ( !is_string(
$blob ) && !is_int(
$blob ) ) {
45 if ( $value !==
false ) {
46 $casToken = (string)
$blob;
52 protected function doCas( $casToken, $key, $value, $exptime = 0, $flags = 0 ) {
53 if ( !wincache_lock( $key ) ) {
58 $this->
doGet( $key, self::READ_LATEST, $curCasToken );
59 if ( $casToken === $curCasToken ) {
60 $success = $this->
set( $key, $value, $exptime, $flags );
63 __METHOD__ .
' failed due to race condition for {key}.',
70 wincache_unlock( $key );
75 protected function doSet( $key, $value, $exptime = 0, $flags = 0 ) {
76 $result = wincache_ucache_set( $key, $this->
serialize( $value ), $exptime );
81 return ( $result === [] || $result ===
true );
84 protected function doAdd( $key, $value, $exptime = 0, $flags = 0 ) {
85 if ( wincache_ucache_exists( $key ) ) {
89 $result = wincache_ucache_add( $key, $this->
serialize( $value ), $exptime );
94 return ( $result === [] || $result ===
true );
97 protected function doDelete( $key, $flags = 0 ) {
98 wincache_ucache_delete( $key );
112 function ( $arg ) use ( &$charsLeft ) {
114 if ( $charsLeft > 33 && strlen( $arg ) > $charsLeft ) {
115 $arg =
'#' . md5( $arg );
118 $charsLeft -= strlen( $arg );
124 if ( $charsLeft < 0 ) {
125 return $keyspace .
':BagOStuff-long-key:##' . md5( implode(
':',
$args ) );
131 public function incr( $key, $value = 1, $flags = 0 ) {
132 if ( !wincache_lock( $key ) ) {
136 $n = $this->
doGet( $key );
138 $n = max( $n + (
int)$value, 0 );
139 $oldTTL = wincache_ucache_info(
false, $key )[
"ucache_entries"][1][
"ttl_seconds"];
140 $this->
set( $key, $n, $oldTTL );
145 wincache_unlock( $key );
150 public function decr( $key, $value = 1, $flags = 0 ) {
151 return $this->
incr( $key, -$value, $flags );