From 508d8ee79b7834ce0451cc0c11e0471e6d9711ca Mon Sep 17 00:00:00 2001 From: Erik Bernhardson Date: Wed, 4 Mar 2015 16:00:10 -0800 Subject: [PATCH] objectcache: Ensure an integer put into memcached comes out an integer Some parts of resourceloader put an integer into the BagOStuff and rejects any value it pulls back out that is not an integer. This patch updates the memcached client behind the BagOStuff to flag integer values and convert them back to integer when recieved. The end result is shaving several seconds off the time it takes to request a CSS or JS file in certain configurations. Bug: 60563 Change-Id: Ie4dc8cf2c2cd232a2c167b4075ff4254b656bcbc --- includes/objectcache/MemcachedClient.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/includes/objectcache/MemcachedClient.php b/includes/objectcache/MemcachedClient.php index 6912864d16..5010b8998a 100644 --- a/includes/objectcache/MemcachedClient.php +++ b/includes/objectcache/MemcachedClient.php @@ -94,6 +94,11 @@ class MWMemcached { */ const COMPRESSED = 2; + /** + * Flag: indicates data is an integer + */ + const INTVAL = 4; + // }}} /** @@ -979,6 +984,8 @@ class MWMemcached { */ if ( $flags & self::SERIALIZED ) { $ret[$rkey] = unserialize( $ret[$rkey] ); + } elseif ( $flags & self::INTVAL ) { + $ret[$rkey] = intval( $ret[$rkey] ); } } @@ -1027,7 +1034,9 @@ class MWMemcached { $flags = 0; - if ( !is_scalar( $val ) ) { + if ( is_int( $val ) ) { + $flags |= self::INTVAL; + } elseif ( !is_scalar( $val ) ) { $val = serialize( $val ); $flags |= self::SERIALIZED; if ( $this->_debug ) { -- 2.20.1