aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Lib/Cache.php
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2024-01-27 16:36:26 +0000
committerMario <mario@mariovavti.com>2024-01-27 16:36:26 +0000
commit5e780ba089aa8493eb5bec30558345b070ef808c (patch)
treeb206fac1263c23fccf6311056f88763f5dc6aed7 /Zotlabs/Lib/Cache.php
parentc0a7dfe2f6554fc66e753c456551dd580c479820 (diff)
downloadvolse-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/Cache.php')
-rw-r--r--Zotlabs/Lib/Cache.php16
1 files changed, 9 insertions, 7 deletions
diff --git a/Zotlabs/Lib/Cache.php b/Zotlabs/Lib/Cache.php
index 60bf64611..f3f520496 100644
--- a/Zotlabs/Lib/Cache.php
+++ b/Zotlabs/Lib/Cache.php
@@ -17,8 +17,8 @@ class Cache {
*/
public static function get($key, $age = '') {
-
- $hash = hash('whirlpool',$key);
+// $hash = hash('whirlpool',$key);
+ $hash = uuid_from_url($key);
$r = q("SELECT v FROM cache WHERE k = '%s' AND updated > %s - INTERVAL %s LIMIT 1",
dbesc($hash),
@@ -32,23 +32,25 @@ class Cache {
}
public static function set($key,$value) {
+// $hash = hash('whirlpool',$key);
+ $hash = uuid_from_url($key);
- $hash = hash('whirlpool',$key);
-
- $r = q("SELECT * FROM cache WHERE k = '%s' limit 1",
+ $r = q("SELECT * FROM cache WHERE k = '%s' LIMIT 1",
dbesc($hash)
);
if($r) {
q("UPDATE cache SET v = '%s', updated = '%s' WHERE k = '%s'",
dbesc($value),
dbesc(datetime_convert()),
- dbesc($hash));
+ dbesc($hash)
+ );
}
else {
q("INSERT INTO cache (k, v, updated) VALUES ('%s', '%s', '%s')",
dbesc($hash),
dbesc($value),
- dbesc(datetime_convert()));
+ dbesc(datetime_convert())
+ );
}
}
}