first commit

This commit is contained in:
Claudecio Martins
2026-06-16 10:04:10 -03:00
commit a951944997
4463 changed files with 419677 additions and 0 deletions
+30
View File
@@ -0,0 +1,30 @@
<?php
namespace WorkbloomERP\Utils;
use WorkbloomERP\Services\CacheService;
use WorkbloomERP\Exceptions\AppException;
class CacheUtil {
public static function set(string $key, int $ttl, mixed $value): bool {
return CacheService::set(
key: $key,
value: is_string($value) ? $value : json_encode(
value: match (true) {
is_array($value), is_object($value) => $value,
default => throw new AppException(message: 'Valor para cache deve ser string, array ou objeto.', code: 400)
},
flags: JSON_UNESCAPED_UNICODE
),
ttl: max(-1, $ttl)
);
}
public static function get(string $key): ?array {
$cachedValue = CacheService::get(key: $key);
return $cachedValue ? json_decode($cachedValue, true) : null;
}
public static function delete(array $keys): bool {
return CacheService::del(keys: $keys);
}
}