diff options
Diffstat (limited to 'Zotlabs/Lib/ObjCache.php')
| -rw-r--r-- | Zotlabs/Lib/ObjCache.php | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/Zotlabs/Lib/ObjCache.php b/Zotlabs/Lib/ObjCache.php new file mode 100644 index 000000000..618522cf2 --- /dev/null +++ b/Zotlabs/Lib/ObjCache.php @@ -0,0 +1,40 @@ +<?php + +namespace Zotlabs\Lib; + +class ObjCache +{ + public static function Get($path, $type = 'as') + { + if (!$path) { + return []; + } + + $localpath = Hashpath::path($path, 'store/[data]/[obj]/' . $type, 2, alg: 'sha256'); + if (file_exists($localpath)) { + return unserialise(file_get_contents($localpath)); + } + + return []; + } + + public static function Set($path, $content, $type = 'as') { + if (!$path) { + return; + } + + $localpath = Hashpath::path($path, 'store/[data]/[obj]/' . $type, 2, alg: 'sha256'); + file_put_contents($localpath, serialise($content)); + } + + public static function Delete($path, $type = 'as') { + if (!$path) { + return; + } + + $localpath = Hashpath::path($path, 'store/[data]/[obj]/' . $type, 2, alg: 'sha256'); + if (file_exists($localpath)) { + unlink($localpath); + } + } +} |
