diff --git a/lib/classes/StudipCache.class.php b/lib/classes/StudipCache.class.php index 79e80e36f5f2008d26b7b8ec55efa19157b9f477..ba929f9bcffe9d764ebd80a3b651673fe2dc2a44 100644 --- a/lib/classes/StudipCache.class.php +++ b/lib/classes/StudipCache.class.php @@ -59,4 +59,36 @@ interface StudipCache * @return bool returns TRUE on success or FALSE on failure. */ public function write($name, $content, $expires = self::DEFAULT_EXPIRATION); + + /** + * @return string A translateable display name for this cache class. + */ + public static function getDisplayName(): string; + + /** + * Get some statistics from cache, like number of entries, hit rate or + * whatever the underlying cache provides. + * Results are returned in form of an array like + * "[ + * [ + * 'name' => <displayable name> + * 'value' => <value of the current stat> + * ] + * ]" + * + * @return array + */ + public function getStats(): array; + + /** + * Return the Vue component name and props that handle configuration. + * The associative array is of the form + * [ + * 'component' => <Vue component name>, + * 'props' => <Properties for component> + * ] + * + * @return array + */ + public static function getConfig(): array; } diff --git a/lib/classes/StudipCacheProxy.php b/lib/classes/StudipCacheProxy.php index 74df560789a721b5917370c5a5dfd44d544d05c1..686f8129d687e130f474167b32ff4f14a2096532 100644 --- a/lib/classes/StudipCacheProxy.php +++ b/lib/classes/StudipCacheProxy.php @@ -99,4 +99,19 @@ class StudipCacheProxy implements StudipCache return $this->actual_cache->write($key, $content, $expires); } + + public static function getDisplayName(): string + { + return static::class; + } + + public function getStats(): array + { + return $this->actual_cache->getStats(); + } + + public static function getConfig(): array + { + return []; + } } diff --git a/lib/classes/StudipDbCache.class.php b/lib/classes/StudipDbCache.class.php index 38fdee840fbf3a3a6e75b4d499131dcc60b7edc3..865825e25880fb1fa72fe9ef0584c609a52add4c 100644 --- a/lib/classes/StudipDbCache.class.php +++ b/lib/classes/StudipDbCache.class.php @@ -7,7 +7,7 @@ * * @author Elmar Ludwig <elmar.ludwig@uos.de> */ -class StudipDbCache implements StudipSystemCache +class StudipDbCache implements StudipCache { /** diff --git a/lib/classes/StudipFileCache.class.php b/lib/classes/StudipFileCache.class.php index 8e46d253379d6e72c4f8f34bad97e5c58ae3449f..9eae66c1fba9967f099a6e56310791895c08d9eb 100644 --- a/lib/classes/StudipFileCache.class.php +++ b/lib/classes/StudipFileCache.class.php @@ -31,7 +31,7 @@ * @author André Noack <noack@data-quest.de> * @version 2 */ -class StudipFileCache implements StudipSystemCache +class StudipFileCache implements StudipCache { use StudipCacheKeyTrait; @@ -236,8 +236,6 @@ class StudipFileCache implements StudipSystemCache /** * Return statistics. * - * @StudipSystemCache::getStats() - * * @return array|array[] */ public function getStats(): array @@ -253,8 +251,6 @@ class StudipFileCache implements StudipSystemCache /** * Return the Vue component name and props that handle configuration. * - * @see StudipSystemCache::getConfig() - * * @return array */ public static function getConfig(): array diff --git a/lib/classes/StudipMemcachedCache.php b/lib/classes/StudipMemcachedCache.php index 619a61ed91cd2880abcebd54fc210588687852b6..0e44dd57e1c5176468afc0db610ff47cd2099bea 100644 --- a/lib/classes/StudipMemcachedCache.php +++ b/lib/classes/StudipMemcachedCache.php @@ -21,7 +21,7 @@ * @since 5.0 */ -class StudipMemcachedCache implements StudipSystemCache +class StudipMemcachedCache implements StudipCache { use StudipCacheKeyTrait; diff --git a/lib/classes/StudipMemoryCache.class.php b/lib/classes/StudipMemoryCache.class.php index 57b35f9a4dfd5d827cfbb8478a0fde3d66d7aae8..d38385a8ec40fbae2e97a505f3b3a85036a06cd7 100644 --- a/lib/classes/StudipMemoryCache.class.php +++ b/lib/classes/StudipMemoryCache.class.php @@ -66,4 +66,19 @@ class StudipMemoryCache implements StudipCache return true; } + + public static function getDisplayName(): string + { + return 'Memory cache'; + } + + public function getStats(): array + { + return []; + } + + public static function getConfig(): array + { + return []; + } } diff --git a/lib/classes/StudipRedisCache.class.php b/lib/classes/StudipRedisCache.class.php index 43a585f7ba1b9a2a19d57493c1b80d00b4a355e5..c485b787b52ff135c7476e37d9f37b07c4ede57d 100644 --- a/lib/classes/StudipRedisCache.class.php +++ b/lib/classes/StudipRedisCache.class.php @@ -8,7 +8,7 @@ * @subpackage cache * @since Stud.IP 5.0 */ -class StudipRedisCache implements StudipSystemCache +class StudipRedisCache implements StudipCache { use StudipCacheKeyTrait; diff --git a/lib/classes/StudipSystemCache.class.php b/lib/classes/StudipSystemCache.class.php deleted file mode 100644 index 895d1216653b2374187b56669888e98ed1d3ea1b..0000000000000000000000000000000000000000 --- a/lib/classes/StudipSystemCache.class.php +++ /dev/null @@ -1,49 +0,0 @@ -<?php -/** - * An interface which has to be implemented by caches available for administration - * via Stud.IP GUI - * - * @package studip - * @subpackage lib - * - * @author Thomas Hackl <studip@thomas-hackl.name> - * @copyright 2021 Stud.IP Core-Group - * @since Stud.IP 5.0 - * @license GPL2 or any later version - */ - -interface StudipSystemCache extends StudipCache -{ - - /** - * @return string A translateable display name for this cache class. - */ - public static function getDisplayName(): string; - - /** - * Get some statistics from cache, like number of entries, hit rate or - * whatever the underlying cache provides. - * Results are returned in form of an array like - * "[ - * [ - * 'name' => <displayable name> - * 'value' => <value of the current stat> - * ] - * ]" - * - * @return array - */ - public function getStats(): array; - - /** - * Return the Vue component name and props that handle configuration. - * The associative array is of the form - * [ - * 'component' => <Vue component name>, - * 'props' => <Properties for component> - * ] - * - * @return array - */ - public static function getConfig(): array; -}