- public function set($key, &$value) {
- if (!apc_store($this->_prefix . $key, $value, $this->_timeout)) {
+ public function set($key, $value, $ttl = NULL) {
+ CRM_Utils_Cache::assertValidKey($key);
+ if (is_int($ttl) && $ttl <= 0) {
+ return $this->delete($key);
+ }
+
+ $ttl = CRM_Utils_Date::convertCacheTtl($ttl, $this->_timeout);
+ $expires = time() + $ttl;
+ if (!apc_store($this->_prefix . $key, ['e' => $expires, 'v' => $value], $ttl)) {