mirror of
https://framagit.org/hubzilla/core.git
synced 2026-06-21 00:52:33 -04:00
41 lines
817 B
PHP
41 lines
817 B
PHP
<?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 json_unserialize(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, json_serialize($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);
|
|
}
|
|
}
|
|
}
|