1
0
mirror of https://github.com/newnius/YAO-portal.git synced 2025-12-13 09:06:43 +00:00

init & add agent & add job

This commit is contained in:
2019-01-15 10:02:28 +08:00
parent 71f1f10e2c
commit d0a4b891b5
321 changed files with 24657 additions and 1 deletions

44
util4p/RedisDAO.class.php Executable file
View File

@@ -0,0 +1,44 @@
<?php
require_once('CRObject.class.php');
if (!class_exists('Predis\Client')) {
header('HTTP/1.1 500 Internal Server Error');
var_dump('predis (github.com/nrk/predis.git) required');
exit;
}
class RedisDAO
{
private static $scheme = 'tcp';
private static $host = 'localhost';
private static $port = 6379;
private static $show_error = false;
public static function configure(CRObject $config)
{
self::$scheme = $config->get('scheme', self::$scheme);
self::$host = $config->get('host', self::$host);
self::$port = $config->getInt('port', self::$port);
self::$show_error = $config->getBool('show_error', self::$show_error);
}
public static function instance()
{
try {
$redis = new Predis\Client(
array(
'scheme' => RedisDAO::$scheme,
'host' => RedisDAO::$host,
'port' => RedisDAO::$port
)
);
$redis->connect();
return $redis;
} catch (Exception $e) {
if (self::$show_error)
var_dump($e->getMessage());
return null;
}
}
}