Skip to content

Commit

Permalink
Merge pull request #12427 from totten/5.4-sqlgroup-ttl-1
Browse files Browse the repository at this point in the history
(dev/core#174) CRM_Utils_Cache_SqlGroup - Refine trivial TTL handling to stabilize tests
  • Loading branch information
eileenmcnaughton authored Jul 6, 2018
2 parents ed2c816 + 13ca7eb commit edf0e41
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion CRM/Utils/Cache/SqlGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,12 @@ public function set($key, $value, $ttl = NULL) {
throw new \CRM_Utils_Cache_CacheException("SqlGroup: Failed to acquire lock on cache key.");
}

if (is_int($ttl) && $ttl <= 0) {
return $this->delete($key);
}

$dataExists = CRM_Core_DAO::singleValueQuery("SELECT COUNT(*) FROM {$this->table} WHERE {$this->where($key)}");
$expires = CRM_Utils_Date::convertCacheTtlToExpires($ttl, self::DEFAULT_TTL);
$expires = round(microtime(1)) + CRM_Utils_Date::convertCacheTtl($ttl, self::DEFAULT_TTL);

$dataSerialized = CRM_Core_BAO_Cache::encode($value);

Expand Down

0 comments on commit edf0e41

Please sign in to comment.