From dfc650aa239d3a2c028d0ba13132ce75b4f4c0b4 Mon Sep 17 00:00:00 2001 From: VirtualTam Date: Mon, 3 Dec 2018 00:08:04 +0100 Subject: namespacing: \Shaarli\Feed\{Cache,CachedPage,FeedBuilder} Signed-off-by: VirtualTam --- application/feed/CachedPage.php | 61 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 application/feed/CachedPage.php (limited to 'application/feed/CachedPage.php') diff --git a/application/feed/CachedPage.php b/application/feed/CachedPage.php new file mode 100644 index 00000000..1c51ac73 --- /dev/null +++ b/application/feed/CachedPage.php @@ -0,0 +1,61 @@ +cacheDir = $cacheDir; + $this->filename = $this->cacheDir . '/' . sha1($url) . '.cache'; + $this->shouldBeCached = $shouldBeCached; + } + + /** + * Returns the cached version of a page, if it exists and should be cached + * + * @return string a cached version of the page if it exists, null otherwise + */ + public function cachedVersion() + { + if (!$this->shouldBeCached) { + return null; + } + if (is_file($this->filename)) { + return file_get_contents($this->filename); + } + return null; + } + + /** + * Puts a page in the cache + * + * @param string $pageContent XML content to cache + */ + public function cache($pageContent) + { + if (!$this->shouldBeCached) { + return; + } + file_put_contents($this->filename, $pageContent); + } +} -- cgit v1.2.3 From f24896b237e40718fb6eaa2869592eb0855a47fd Mon Sep 17 00:00:00 2001 From: VirtualTam Date: Mon, 3 Dec 2018 01:10:39 +0100 Subject: namespacing: \Shaarli\Bookmark\LinkDB Signed-off-by: VirtualTam --- application/feed/CachedPage.php | 1 + 1 file changed, 1 insertion(+) (limited to 'application/feed/CachedPage.php') diff --git a/application/feed/CachedPage.php b/application/feed/CachedPage.php index 1c51ac73..d809bdd9 100644 --- a/application/feed/CachedPage.php +++ b/application/feed/CachedPage.php @@ -1,6 +1,7 @@