Skip to content
This repository has been archived by the owner on Mar 6, 2021. It is now read-only.

Commit

Permalink
Improve Cache usage
Browse files Browse the repository at this point in the history
Remove throwing exception and allow using local cache even if the cache
is not writable
  • Loading branch information
nyamsprod committed Nov 22, 2017
1 parent 9d07e44 commit 5ceb029
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/PublicSuffix/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,6 @@ public function __construct(string $cache_path = '')
$this->mkdir($cache_path); // ensure that the parent path exists
}

if (!is_writable($cache_path.DIRECTORY_SEPARATOR)) {
throw new CacheException(sprintf('cache path is not writable: %s', $cache_path));
}

$this->cache_path = $cache_path;
}

Expand Down Expand Up @@ -113,6 +109,10 @@ public function get($key, $default = null)
*/
public function set($key, $value, $ttl = null)
{
if (!is_writable($this->cache_path.DIRECTORY_SEPARATOR)) {
return false;
}

$expires_at = $this->getExpireAt($ttl);
$path = $this->getPath($key);
$dir = dirname($path);
Expand Down

0 comments on commit 5ceb029

Please sign in to comment.