mirror of
https://gitee.com/koogua/course-tencent-cloud.git
synced 2025-07-23 08:26:40 +08:00
优化Providers
This commit is contained in:
parent
fb5feb0759
commit
f7a3c0d736
@ -26,15 +26,19 @@ class Annotation extends Provider
|
|||||||
$this->di->setShared($this->serviceName, function () use ($config) {
|
$this->di->setShared($this->serviceName, function () use ($config) {
|
||||||
|
|
||||||
if ($config->get('env') == ENV_DEV) {
|
if ($config->get('env') == ENV_DEV) {
|
||||||
|
|
||||||
$annotations = new MemoryAnnotations();
|
$annotations = new MemoryAnnotations();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
$statsKey = '_ANNOTATION_';
|
$statsKey = '_ANNOTATION_';
|
||||||
|
|
||||||
$annotations = new RedisAnnotations([
|
$annotations = new RedisAnnotations([
|
||||||
'host' => $config->path('redis.host'),
|
'host' => $config->path('redis.host'),
|
||||||
'port' => $config->path('redis.port'),
|
'port' => $config->path('redis.port'),
|
||||||
'auth' => $config->path('redis.auth'),
|
'auth' => $config->path('redis.auth'),
|
||||||
'index' => $config->path('redis.index') ?: 0,
|
'index' => $config->path('redis.index'),
|
||||||
'lifetime' => $config->path('annotation.lifetime') ?: 30 * 86400,
|
'lifetime' => $config->path('annotation.lifetime'),
|
||||||
'prefix' => $statsKey . ':',
|
'prefix' => $statsKey . ':',
|
||||||
'statsKey' => $statsKey,
|
'statsKey' => $statsKey,
|
||||||
]);
|
]);
|
||||||
|
@ -33,7 +33,7 @@ class Cache extends Provider
|
|||||||
'host' => $config->path('redis.host'),
|
'host' => $config->path('redis.host'),
|
||||||
'port' => $config->path('redis.port'),
|
'port' => $config->path('redis.port'),
|
||||||
'auth' => $config->path('redis.auth'),
|
'auth' => $config->path('redis.auth'),
|
||||||
'index' => $config->path('redis.index') ?: 0,
|
'index' => $config->path('redis.index'),
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -42,8 +42,11 @@ class Database extends Provider
|
|||||||
$connection = new MySqlAdapter($options);
|
$connection = new MySqlAdapter($options);
|
||||||
|
|
||||||
if ($config->get('env') == ENV_DEV) {
|
if ($config->get('env') == ENV_DEV) {
|
||||||
|
|
||||||
$eventsManager = new EventsManager();
|
$eventsManager = new EventsManager();
|
||||||
|
|
||||||
$eventsManager->attach('db', new DbListener());
|
$eventsManager->attach('db', new DbListener());
|
||||||
|
|
||||||
$connection->setEventsManager($eventsManager);
|
$connection->setEventsManager($eventsManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,15 +26,19 @@ class MetaData extends Provider
|
|||||||
$this->di->setShared($this->serviceName, function () use ($config) {
|
$this->di->setShared($this->serviceName, function () use ($config) {
|
||||||
|
|
||||||
if ($config->get('env') == ENV_DEV) {
|
if ($config->get('env') == ENV_DEV) {
|
||||||
|
|
||||||
$metaData = new MemoryMetaData();
|
$metaData = new MemoryMetaData();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
$statsKey = '_METADATA_';
|
$statsKey = '_METADATA_';
|
||||||
|
|
||||||
$metaData = new RedisMetaData([
|
$metaData = new RedisMetaData([
|
||||||
'host' => $config->path('redis.host'),
|
'host' => $config->path('redis.host'),
|
||||||
'port' => $config->path('redis.port'),
|
'port' => $config->path('redis.port'),
|
||||||
'auth' => $config->path('redis.auth'),
|
'auth' => $config->path('redis.auth'),
|
||||||
'index' => $config->path('redis.index') ?: 0,
|
'index' => $config->path('redis.index'),
|
||||||
'lifetime' => $config->path('metadata.lifetime') ?: 30 * 86400,
|
'lifetime' => $config->path('metadata.lifetime'),
|
||||||
'prefix' => $statsKey . ':',
|
'prefix' => $statsKey . ':',
|
||||||
'statsKey' => $statsKey,
|
'statsKey' => $statsKey,
|
||||||
]);
|
]);
|
||||||
|
@ -28,8 +28,8 @@ class Session extends Provider
|
|||||||
'host' => $config->path('redis.host'),
|
'host' => $config->path('redis.host'),
|
||||||
'port' => $config->path('redis.port'),
|
'port' => $config->path('redis.port'),
|
||||||
'auth' => $config->path('redis.auth'),
|
'auth' => $config->path('redis.auth'),
|
||||||
'index' => $config->path('redis.index') ?: 0,
|
'index' => $config->path('redis.index'),
|
||||||
'lifetime' => $config->path('session.lifetime') ?: 24 * 3600,
|
'lifetime' => $config->path('session.lifetime'),
|
||||||
'prefix' => '_SESSION_:',
|
'prefix' => '_SESSION_:',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
@ -99,6 +99,16 @@ class Volt extends Provider
|
|||||||
return 'kg_anonymous(' . $resolvedArgs . ')';
|
return 'kg_anonymous(' . $resolvedArgs . ')';
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$compiler->addFilter('split', function ($resolvedArgs, $exprArgs) use ($compiler) {
|
||||||
|
$firstArgument = $compiler->expression($exprArgs[0]['expr']);
|
||||||
|
if (isset($exprArgs[1])) {
|
||||||
|
$secondArgument = $compiler->expression($exprArgs[1]['expr']);
|
||||||
|
} else {
|
||||||
|
$secondArgument = '';
|
||||||
|
}
|
||||||
|
return sprintf('explode(%s,%s)', $secondArgument, $firstArgument);
|
||||||
|
});
|
||||||
|
|
||||||
return $volt;
|
return $volt;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user