aboutsummaryrefslogtreecommitdiff
path: root/lib/CacheInterface.php
diff options
context:
space:
mode:
authorGravatar Dag <me@dvikan.no> 2023-07-06 15:10:30 +0200
committerGravatar GitHub <noreply@github.com> 2023-07-06 15:10:30 +0200
commitcaac7f572cf335e96ee99f8a3af7395df471baf8 (patch)
treefec5678b9f30d84d0082e1f52764d8f67f671d36 /lib/CacheInterface.php
parentf8801d8cb3d99711808a83176f767b6f6f4ec5a9 (diff)
downloadrss-bridge-caac7f572cf335e96ee99f8a3af7395df471baf8.tar.gz
rss-bridge-caac7f572cf335e96ee99f8a3af7395df471baf8.tar.zst
rss-bridge-caac7f572cf335e96ee99f8a3af7395df471baf8.zip
refacor: improve cache interface (#3492)
* fix: proper typehint on setScope * refactor: type hint setKey() * typehint
Diffstat (limited to 'lib/CacheInterface.php')
-rw-r--r--lib/CacheInterface.php60
1 files changed, 4 insertions, 56 deletions
diff --git a/lib/CacheInterface.php b/lib/CacheInterface.php
index b332e21b..414a9c84 100644
--- a/lib/CacheInterface.php
+++ b/lib/CacheInterface.php
@@ -1,68 +1,16 @@
<?php
-/**
- * This file is part of RSS-Bridge, a PHP project capable of generating RSS and
- * Atom feeds for websites that don't have one.
- *
- * For the full license information, please view the UNLICENSE file distributed
- * with this source code.
- *
- * @package Core
- * @license http://unlicense.org/ UNLICENSE
- * @link https://github.com/rss-bridge/rss-bridge
- */
-
-/**
- * The cache interface
- */
interface CacheInterface
{
- /**
- * Set scope of the current cache
- *
- * If $scope is an empty string, the cache is set to a global context.
- *
- * @param string $scope The scope the data is related to
- */
- public function setScope($scope);
+ public function setScope(string $scope): void;
- /**
- * Set key to assign the current data
- *
- * Since $key can be anything, the cache implementation must ensure to
- * assign the related data reliably; most commonly by serializing and
- * hashing the key in an appropriate way.
- *
- * @param array $key The key the data is related to
- */
- public function setKey($key);
+ public function setKey(array $key): void;
- /**
- * Loads data from cache
- *
- * @return mixed The cached data or null
- */
public function loadData();
- /**
- * Stores data to the cache
- *
- * @param mixed $data The data to store
- * @return self The cache object
- */
- public function saveData($data);
+ public function saveData($data): void;
- /**
- * Returns the modification time of the current cache item.
- * In unix timestamp.
- * Example: 1688570578
- */
public function getTime(): ?int;
- /**
- * Removes any data that is older than the specified age from cache
- *
- * @param int $seconds The cache age in seconds
- */
- public function purgeCache($seconds);
+ public function purgeCache(int $seconds): void;
}