* @param string $key
* @param mixed $value
* @param null|int|\DateInterval $ttl
+ *
* @return bool
+ *
+ * @throws \CRM_Core_Exception
+ * @throws \CRM_Utils_Cache_CacheException
+ * @throws \CRM_Utils_Cache_InvalidArgumentException
*/
public function set($key, $value, $ttl = NULL) {
CRM_Utils_Cache::assertValidKey($key);
2 => [time(), 'Positive'],
3 => [$expires, 'Positive'],
];
- $dao = CRM_Core_DAO::executeQuery($sql, $args, FALSE, NULL, FALSE, FALSE);
+ CRM_Core_DAO::executeQuery($sql, $args, TRUE, NULL, FALSE, FALSE);
}
else {
$sql = "INSERT INTO {$this->table} (group_name,path,data,created_date,expired_date) VALUES (%1,%2,%3,FROM_UNIXTIME(%4),FROM_UNIXTIME(%5))";
$args = [
- 1 => [$this->group, 'String'],
+ 1 => [(string) $this->group, 'String'],
2 => [$key, 'String'],
3 => [$dataSerialized, 'String'],
4 => [time(), 'Positive'],
5 => [$expires, 'Positive'],
];
- $dao = CRM_Core_DAO::executeQuery($sql, $args, FALSE, NULL, FALSE, FALSE);
+ CRM_Core_DAO::executeQuery($sql, $args, TRUE, NULL, FALSE, FALSE);
}
$lock->release();
* @param mixed $default
*
* @return mixed
+ *
+ * @throws \CRM_Utils_Cache_InvalidArgumentException
*/
public function get($key, $default = NULL) {
CRM_Utils_Cache::assertValidKey($key);
return (isset($this->expiresCache[$key]) && time() < $this->expiresCache[$key]) ? $this->reobjectify($this->valueCache[$key]) : $default;
}
+ /**
+ * @param mixed $value
+ *
+ * @return object
+ */
private function reobjectify($value) {
return is_object($value) ? unserialize(serialize($value)) : $value;
}
/**
- * @param $key
+ * @param string $key
* @param null $default
*
* @return mixed
/**
* @param string $key
+ *
* @return bool
+ * @throws \CRM_Utils_Cache_InvalidArgumentException
*/
public function delete($key) {
CRM_Utils_Cache::assertValidKey($key);
public function flush() {
if ($this->group == CRM_Utils_Cache::cleanKey('CiviCRM Search PrevNextCache') &&
Civi::service('prevnext') instanceof CRM_Core_PrevNextCache_Sql) {
- // Use the standard PrevNextCache cleanup function here not just delete from civicrm_cache
- CRM_Core_BAO_PrevNextCache::cleanupCache();
+ Civi::service('prevnext')->cleanup();
}
else {
CRM_Core_DAO::executeQuery("DELETE FROM {$this->table} WHERE {$this->where()}");