aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Lib
diff options
context:
space:
mode:
authorMax Kostikov <max@kostikov.co>2020-01-05 11:49:36 +0100
committerMax Kostikov <max@kostikov.co>2020-01-05 11:49:36 +0100
commit41ce2da080d72dbfd2c47a3973fe3c43672adb4d (patch)
tree88d71b2d413b1ffb38d69a84fa678f832e22ebf9 /Zotlabs/Lib
parent3c59303b681fea19db7751d2362329ad2f7b0862 (diff)
downloadvolse-hubzilla-41ce2da080d72dbfd2c47a3973fe3c43672adb4d.tar.gz
volse-hubzilla-41ce2da080d72dbfd2c47a3973fe3c43672adb4d.tar.bz2
volse-hubzilla-41ce2da080d72dbfd2c47a3973fe3c43672adb4d.zip
Add age choice on cached item retrieve
Diffstat (limited to 'Zotlabs/Lib')
-rw-r--r--Zotlabs/Lib/Cache.php13
1 files changed, 11 insertions, 2 deletions
diff --git a/Zotlabs/Lib/Cache.php b/Zotlabs/Lib/Cache.php
index 878201a42..bb7bbbff0 100644
--- a/Zotlabs/Lib/Cache.php
+++ b/Zotlabs/Lib/Cache.php
@@ -7,14 +7,23 @@ namespace Zotlabs\Lib;
*/
class Cache {
- public static function get($key) {
+
+ /**
+ * @brief Returns cached content
+ *
+ * @param string $key
+ * @param string $age in SQL format, default is '30 DAY'
+ * @return string
+ * /
+
+ public static function get($key, $age = '') {
$hash = hash('whirlpool',$key);
$r = q("SELECT v FROM cache WHERE k = '%s' AND updated > %s - INTERVAL %s LIMIT 1",
dbesc($hash),
db_utcnow(),
- db_quoteinterval(get_config('system','object_cache_days', '30') . ' DAY')
+ db_quoteinterval(($age ? $age : get_config('system','object_cache_days', '30') . ' DAY'))
);
if ($r)