diff options
author | Mario <mario@mariovavti.com> | 2024-01-27 16:36:26 +0000 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2024-01-27 16:36:26 +0000 |
commit | 5e780ba089aa8493eb5bec30558345b070ef808c (patch) | |
tree | b206fac1263c23fccf6311056f88763f5dc6aed7 /Zotlabs/Lib/ASCache.php | |
parent | c0a7dfe2f6554fc66e753c456551dd580c479820 (diff) | |
download | volse-hubzilla-5e780ba089aa8493eb5bec30558345b070ef808c.tar.gz volse-hubzilla-5e780ba089aa8493eb5bec30558345b070ef808c.tar.bz2 volse-hubzilla-5e780ba089aa8493eb5bec30558345b070ef808c.zip |
implement short time object cache to reduce network calls and some cleanup
Diffstat (limited to 'Zotlabs/Lib/ASCache.php')
-rw-r--r-- | Zotlabs/Lib/ASCache.php | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/Zotlabs/Lib/ASCache.php b/Zotlabs/Lib/ASCache.php new file mode 100644 index 000000000..63bd73ea7 --- /dev/null +++ b/Zotlabs/Lib/ASCache.php @@ -0,0 +1,33 @@ +<?php /** @file */ + +namespace Zotlabs\Lib; + + /** + * A wrapper for the cache api + */ + +class ASCache { + public static function isEnabled() { + return Config::Get('system', 'as_object_cache_enabled', false); + } + + public static function getAge() { + return Config::Get('system', 'as_object_cache_time', '10 MINUTE'); + } + + public static function Get($key) { + if (!self::isEnabled()) { + return; + } + + return Cache::get($key, self::getAge()); + } + + public static function Set($key, $value) { + if (!self::isEnabled()) { + return; + } + + Cache::set($key, $value); + } +} |