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 ) {
77 $result = wincache_ucache_set( $key, $this->
getSerialized( $value, $key ), $ttl );
82 return ( $result === [] || $result ===
true );
85 protected function doAdd( $key, $value, $exptime = 0, $flags = 0 ) {
86 if ( wincache_ucache_exists( $key ) ) {
91 $result = wincache_ucache_add( $key, $this->
getSerialized( $value, $key ), $ttl );
96 return ( $result === [] || $result ===
true );
99 protected function doDelete( $key, $flags = 0 ) {
100 wincache_ucache_delete( $key );
114 function ( $arg ) use ( &$charsLeft ) {
116 if ( $charsLeft > 33 && strlen( $arg ) > $charsLeft ) {
117 $arg =
'#' . md5( $arg );
120 $charsLeft -= strlen( $arg );
126 if ( $charsLeft < 0 ) {
127 return $keyspace .
':BagOStuff-long-key:##' . md5( implode(
':',
$args ) );
133 public function incr( $key, $value = 1, $flags = 0 ) {
134 if ( !wincache_lock( $key ) ) {
138 $n = $this->
doGet( $key );
140 $n = max( $n + (
int)$value, 0 );
141 $oldTTL = wincache_ucache_info(
false, $key )[
"ucache_entries"][1][
"ttl_seconds"];
142 $this->
set( $key, $n, $oldTTL );
147 wincache_unlock( $key );
152 public function decr( $key, $value = 1, $flags = 0 ) {
153 return $this->
incr( $key, -$value, $flags );
Storage medium specific cache for storing items (e.g.
getSerialized( $value, $key)
Get the serialized form a value, using any applicable prepared value.
getExpirationAsTTL( $exptime)
Convert an optionally absolute expiry time to a relative time.
isInteger( $value)
Check if a value is an integer.
Wrapper for WinCache object caching functions; identical interface to the APC wrapper.
doDelete( $key, $flags=0)
Delete an item.
doGet( $key, $flags=0, &$casToken=null)
doCas( $casToken, $key, $value, $exptime=0, $flags=0)
Check and set an item.
doAdd( $key, $value, $exptime=0, $flags=0)
Insert an item if it does not already exist.
decr( $key, $value=1, $flags=0)
Decrease stored value of $key by $value while preserving its TTL.
doSet( $key, $value, $exptime=0, $flags=0)
Set an item.
__construct(array $params=[])
incr( $key, $value=1, $flags=0)
Increase stored value of $key by $value while preserving its TTL.
makeKeyInternal( $keyspace, $args)
Construct a cache key.