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

Commit 5ceb029

Browse files
committed
Improve Cache usage
Remove throwing exception and allow using local cache even if the cache is not writable
1 parent 9d07e44 commit 5ceb029

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/PublicSuffix/Cache.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,6 @@ public function __construct(string $cache_path = '')
6767
$this->mkdir($cache_path); // ensure that the parent path exists
6868
}
6969

70-
if (!is_writable($cache_path.DIRECTORY_SEPARATOR)) {
71-
throw new CacheException(sprintf('cache path is not writable: %s', $cache_path));
72-
}
73-
7470
$this->cache_path = $cache_path;
7571
}
7672

@@ -113,6 +109,10 @@ public function get($key, $default = null)
113109
*/
114110
public function set($key, $value, $ttl = null)
115111
{
112+
if (!is_writable($this->cache_path.DIRECTORY_SEPARATOR)) {
113+
return false;
114+
}
115+
116116
$expires_at = $this->getExpireAt($ttl);
117117
$path = $this->getPath($key);
118118
$dir = dirname($path);

0 commit comments

Comments
 (0)