mirror of https://github.com/MISP/MISP
chg: use adhoc redis implementation for cache as @iglocska suggested
parent
60160cf999
commit
83a115e340
|
@ -255,10 +255,6 @@ Configure::write('Acl.database', 'default');
|
|||
* and their setttings.
|
||||
*/
|
||||
$engine = 'File';
|
||||
if (function_exists('apcu_dec') && (PHP_SAPI !== 'cli' || ini_get('apc.enable_cli'))) {
|
||||
require_once APP . 'Plugin/ApcuCache/Engine/ApcuEngine.php'; // it is not possible to use plugin
|
||||
$engine = 'Apcu'; // faster version of ApcEngine
|
||||
}
|
||||
|
||||
// In development mode, caches should expire quickly.
|
||||
$duration = '+999 days';
|
||||
|
@ -293,11 +289,5 @@ Cache::config('_cake_model_', array(
|
|||
'duration' => $duration
|
||||
));
|
||||
|
||||
Cache::config('misp_short', array(
|
||||
'engine' => $engine,
|
||||
'duration' => '1800', // 30 minutes
|
||||
'prefix' => 'misp_cache_short_',
|
||||
));
|
||||
|
||||
//Comment the following out if you do not with to use the background workers (not recommended)
|
||||
require_once dirname(__DIR__) . '/Vendor/autoload.php';
|
||||
|
|
|
@ -589,9 +589,10 @@ class Taxonomy extends AppModel
|
|||
}
|
||||
|
||||
$key = 'taxonomies_cache:tagName=' . $tagName . "&" . "metaOnly=$metaOnly" . "&" . "fullTaxonomy=$fullTaxonomy";
|
||||
$model = $this;
|
||||
$redis = $this->setupRedisWithException();
|
||||
$taxonomy = json_decode($redis->get($key), true);
|
||||
|
||||
return Cache::remember($key, function () use ($model, $metaOnly, $fullTaxonomy, $splits) {
|
||||
if (!$taxonomy) {
|
||||
if (isset($splits['value'])) {
|
||||
$contain = array(
|
||||
'TaxonomyPredicate' => array(
|
||||
|
@ -606,7 +607,7 @@ class Taxonomy extends AppModel
|
|||
'LOWER(TaxonomyEntry.value)' => mb_strtolower($splits['value']),
|
||||
);
|
||||
}
|
||||
$taxonomy = $model->find('first', array(
|
||||
$taxonomy = $this->find('first', array(
|
||||
'recursive' => -1,
|
||||
'conditions' => array('LOWER(Taxonomy.namespace)' => mb_strtolower($splits['namespace'])),
|
||||
'contain' => $contain
|
||||
|
@ -614,8 +615,6 @@ class Taxonomy extends AppModel
|
|||
if ($metaOnly && !empty($taxonomy)) {
|
||||
$taxonomy = array('Taxonomy' => $taxonomy['Taxonomy']);
|
||||
}
|
||||
|
||||
return $taxonomy;
|
||||
} else {
|
||||
$contain = array('TaxonomyPredicate' => array());
|
||||
if (!$fullTaxonomy) {
|
||||
|
@ -623,7 +622,7 @@ class Taxonomy extends AppModel
|
|||
'LOWER(TaxonomyPredicate.value)' => mb_strtolower($splits['predicate'])
|
||||
);
|
||||
}
|
||||
$taxonomy = $model->find('first', array(
|
||||
$taxonomy = $this->find('first', array(
|
||||
'recursive' => -1,
|
||||
'conditions' => array('LOWER(Taxonomy.namespace)' => mb_strtolower($splits['namespace'])),
|
||||
'contain' => $contain
|
||||
|
@ -631,10 +630,12 @@ class Taxonomy extends AppModel
|
|||
if ($metaOnly && !empty($taxonomy)) {
|
||||
$taxonomy = array('Taxonomy' => $taxonomy['Taxonomy']);
|
||||
}
|
||||
|
||||
return $taxonomy;
|
||||
}
|
||||
}, 'misp_short');
|
||||
|
||||
$redis->setex($key, 1800, $taxonomy);
|
||||
}
|
||||
|
||||
return $taxonomy;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -270,12 +270,6 @@ Cache::config('_cake_core_', array(
|
|||
'duration' => $duration
|
||||
));
|
||||
|
||||
Cache::config('misp_short', array(
|
||||
'engine' => $engine,
|
||||
'duration' => '1800', // 30 minutes
|
||||
'prefix' => 'misp_cache_short_',
|
||||
));
|
||||
|
||||
/**
|
||||
* Configure the cache for model and datasource caches. This cache configuration
|
||||
* is used to store schema descriptions, and table listings in connections.
|
||||
|
|
Loading…
Reference in New Issue