看板初始化提交

This commit is contained in:
zephyr
2026-06-01 21:23:12 -07:00
commit 54a842f4ab
2104 changed files with 241695 additions and 0 deletions
+38
View File
@@ -0,0 +1,38 @@
<?php
namespace Kanboard\Core\Cache;
/**
* Base Class for Cache Drivers
*
* @package Kanboard\Core\Cache
* @author Frederic Guillot
*/
abstract class BaseCache implements CacheInterface
{
/**
* Proxy cache
*
* Note: Arguments must be scalar types
*
* @access public
* @param string $class Class instance
* @param string $method Container method
* @return mixed
*/
public function proxy($class, $method)
{
$args = func_get_args();
array_shift($args);
$key = 'proxy:'.get_class($class).':'.implode(':', $args);
$result = $this->get($key);
if ($result === null) {
$result = call_user_func_array(array($class, $method), array_splice($args, 1));
$this->set($key, $result);
}
return $result;
}
}
+45
View File
@@ -0,0 +1,45 @@
<?php
namespace Kanboard\Core\Cache;
/**
* Interface CacheInterface
*
* @package Kanboard\Core\Cache
* @author Frederic Guillot
*/
interface CacheInterface
{
/**
* Store an item in the cache
*
* @access public
* @param string $key
* @param mixed $value
*/
public function set($key, $value);
/**
* Retrieve an item from the cache by key
*
* @access public
* @param string $key
* @return mixed Null when not found, cached value otherwise
*/
public function get($key);
/**
* Remove all items from the cache
*
* @access public
*/
public function flush();
/**
* Remove an item from the cache
*
* @access public
* @param string $key
*/
public function remove($key);
}
+65
View File
@@ -0,0 +1,65 @@
<?php
namespace Kanboard\Core\Cache;
/**
* Memory Cache Driver
*
* @package Kanboard\Core\Cache
* @author Frederic Guillot
*/
class MemoryCache extends BaseCache
{
/**
* Container
*
* @access private
* @var array
*/
private $storage = array();
/**
* Store an item in the cache
*
* @access public
* @param string $key
* @param mixed $value
*/
public function set($key, $value)
{
$this->storage[$key] = $value;
}
/**
* Retrieve an item from the cache by key
*
* @access public
* @param string $key
* @return mixed Null when not found, cached value otherwise
*/
public function get($key)
{
return isset($this->storage[$key]) ? $this->storage[$key] : null;
}
/**
* Clear all cache
*
* @access public
*/
public function flush()
{
$this->storage = array();
}
/**
* Remove cached value
*
* @access public
* @param string $key
*/
public function remove($key)
{
unset($this->storage[$key]);
}
}