first commit.

This commit is contained in:
kj
2026-10-05 15:08:39 -03:00
commit b7799f9fff
93 changed files with 8966 additions and 0 deletions
+11
View File
@@ -0,0 +1,11 @@
{
"name": "cache",
"version": "0.1.0",
"description": "Caché APCu (APCache)",
"core": { "requires": ">=0.1", "tested": "0.1" },
"php": ">=8.1",
"components": {
"apcache": { "files": ["src/Libs/APCache.php"] }
},
"default": ["apcache"]
}
+60
View File
@@ -0,0 +1,60 @@
<?php
namespace Libs;
/**
* DuckBrain - Microframework
*
* APCache is a simple library that makes use of APC cache.
* Data is stored in memory and does not disappear until
* it expires or is explicitly deleted.
*
* @author: KJ
* @web: https://kj2.me
* @license: MIT
*/
class APCache
{
/**
* Get an item from the cache.
*
* @param string $key
* The key to retrieve.
* @return mixed
* The stored variable or an array of variables on success; FALSE on failure.
*/
public static function get(string $key): mixed
{
return apcu_fetch($key);
}
/**
* Stores or overwrites a key in the cache.
*
* @param string $key
* The key to store.
* @param mixed $data
* The variable to store under the key.
* @param int $expire
* Expiration time for the key in seconds.
* @return bool | array
* Returns TRUE on success or FALSE on failure. An array of error keys on failure.
*/
public static function save(string $key, mixed $data, int $expire = 0): bool|array
{
return apcu_store($key, $data, $expire);
}
/**
* Deletes an item from the cache.
*
* @param string $key
* The key to delete.
* @return boolean | array
* Returns TRUE on success or FALSE on failure. An array of error keys on failure.
*/
public static function delete(string $key): bool|array
{
return apcu_delete($key);
}
}