mirror of
https://git.friendi.ca/friendica/friendica-addons.git
synced 2024-08-19 03:30:58 +00:00
- slim/slim: ^3.1 - symfony/expression-language: ^3.4 - fxp/composer-asset-plugin: ~1.3 - bower-asset/vue: ^2.5 - bower-asset/vue-resource: ^1.5
106 lines
2.2 KiB
PHP
106 lines
2.2 KiB
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of the Symfony package.
|
|
*
|
|
* (c) Fabien Potencier <fabien@symfony.com>
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Symfony\Polyfill\Apcu;
|
|
|
|
/**
|
|
* Apcu for Zend Server Data Cache.
|
|
*
|
|
* @author Kate Gray <opensource@codebykate.com>
|
|
* @author Nicolas Grekas <p@tchwork.com>
|
|
*
|
|
* @internal
|
|
*/
|
|
final class Apcu
|
|
{
|
|
public static function apcu_add($key, $var = null, $ttl = 0)
|
|
{
|
|
if (!is_array($key)) {
|
|
return apc_add($key, $var, $ttl);
|
|
}
|
|
|
|
$errors = array();
|
|
foreach ($key as $k => $v) {
|
|
if (!apc_add($k, $v, $ttl)) {
|
|
$errors[$k] = -1;
|
|
}
|
|
}
|
|
|
|
return $errors;
|
|
}
|
|
|
|
public static function apcu_store($key, $var = null, $ttl = 0)
|
|
{
|
|
if (!is_array($key)) {
|
|
return apc_store($key, $var, $ttl);
|
|
}
|
|
|
|
$errors = array();
|
|
foreach ($key as $k => $v) {
|
|
if (!apc_store($k, $v, $ttl)) {
|
|
$errors[$k] = -1;
|
|
}
|
|
}
|
|
|
|
return $errors;
|
|
}
|
|
|
|
public static function apcu_exists($keys)
|
|
{
|
|
if (!is_array($keys)) {
|
|
return apc_exists($keys);
|
|
}
|
|
|
|
$existing = array();
|
|
foreach ($keys as $k) {
|
|
if (apc_exists($k)) {
|
|
$existing[$k] = true;
|
|
}
|
|
}
|
|
|
|
return $existing;
|
|
}
|
|
|
|
public static function apcu_fetch($key, &$success = null)
|
|
{
|
|
if (!is_array($key)) {
|
|
return apc_fetch($key, $success);
|
|
}
|
|
|
|
$succeeded = true;
|
|
$values = array();
|
|
foreach ($key as $k) {
|
|
$v = apc_fetch($k, $success);
|
|
if ($success) {
|
|
$values[$k] = $v;
|
|
} else {
|
|
$succeeded = false;
|
|
}
|
|
}
|
|
$success = $succeeded;
|
|
|
|
return $values;
|
|
}
|
|
|
|
public static function apcu_delete($key)
|
|
{
|
|
if (!is_array($key)) {
|
|
return apc_delete($key);
|
|
}
|
|
|
|
$success = true;
|
|
foreach ($key as $k) {
|
|
$success = apc_delete($k) && $success;
|
|
}
|
|
|
|
return $success;
|
|
}
|
|
}
|