mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-18 23:43:12 +00:00
Update cache databox
This commit is contained in:
34
lib/classes/cache/databox.class.php
vendored
34
lib/classes/cache/databox.class.php
vendored
@@ -9,6 +9,9 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Alchemy\Phrasea\Application;
|
||||||
|
use Alchemy\Phrasea\Core\Configuration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @package cache
|
* @package cache
|
||||||
@@ -24,7 +27,7 @@ class cache_databox
|
|||||||
* @param int $sbas_id
|
* @param int $sbas_id
|
||||||
* @return cache_databox
|
* @return cache_databox
|
||||||
*/
|
*/
|
||||||
public static function refresh($sbas_id)
|
public static function refresh(Application $app, $sbas_id)
|
||||||
{
|
{
|
||||||
if (self::$refreshing) {
|
if (self::$refreshing) {
|
||||||
return;
|
return;
|
||||||
@@ -32,17 +35,16 @@ class cache_databox
|
|||||||
|
|
||||||
self::$refreshing = true;
|
self::$refreshing = true;
|
||||||
|
|
||||||
$appbox = \appbox::get_instance(\bootstrap::getCore());
|
$databox = $app['phraseanet.appbox']->get_databox((int) $sbas_id);
|
||||||
$databox = $appbox->get_databox((int) $sbas_id);
|
|
||||||
|
|
||||||
$date = new \DateTime('-3 seconds');
|
$date = new \DateTime('-3 seconds');
|
||||||
|
|
||||||
$registry = \registry::get_instance();
|
$registry = $app['phraseanet.registry'];
|
||||||
|
|
||||||
$last_update = null;
|
$last_update = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$last_update = $appbox->get_data_from_cache('memcached_update_' . $sbas_id);
|
$last_update = $app['phraseanet.appbox']->get_data_from_cache('memcached_update_' . $sbas_id);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -58,7 +60,7 @@ class cache_databox
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$connsbas = \connection::getPDOConnection($sbas_id);
|
$connsbas = \connection::getPDOConnection($app, $sbas_id);
|
||||||
|
|
||||||
$sql = 'SELECT type, value FROM memcached WHERE site_id = :site_id';
|
$sql = 'SELECT type, value FROM memcached WHERE site_id = :site_id';
|
||||||
$stmt = $connsbas->prepare($sql);
|
$stmt = $connsbas->prepare($sql);
|
||||||
@@ -98,7 +100,7 @@ class cache_databox
|
|||||||
$stmt->execute($params);
|
$stmt->execute($params);
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
$record = new \record_adapter($sbas_id, $row['value']);
|
$record = new \record_adapter($app, $sbas_id, $row['value']);
|
||||||
$record->get_caption()->delete_data_from_cache();
|
$record->get_caption()->delete_data_from_cache();
|
||||||
|
|
||||||
foreach ($record->get_subdefs() as $subdef) {
|
foreach ($record->get_subdefs() as $subdef) {
|
||||||
@@ -107,8 +109,8 @@ class cache_databox
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
case 'structure':
|
case 'structure':
|
||||||
$appbox->delete_data_from_cache(\appbox::CACHE_LIST_BASES);
|
$app['phraseanet.appbox']->delete_data_from_cache(\appbox::CACHE_LIST_BASES);
|
||||||
$appbox->delete_data_from_cache(\appbox::CACHE_SBAS_IDS);
|
$app['phraseanet.appbox']->delete_data_from_cache(\appbox::CACHE_SBAS_IDS);
|
||||||
|
|
||||||
$sql = 'DELETE FROM memcached
|
$sql = 'DELETE FROM memcached
|
||||||
WHERE site_id = :site_id AND type="structure" AND value = :value';
|
WHERE site_id = :site_id AND type="structure" AND value = :value';
|
||||||
@@ -128,9 +130,9 @@ class cache_databox
|
|||||||
$date = new \DateTime();
|
$date = new \DateTime();
|
||||||
$now = $date->format(DATE_ISO8601);
|
$now = $date->format(DATE_ISO8601);
|
||||||
|
|
||||||
$appbox->set_data_to_cache($now, 'memcached_update_' . $sbas_id);
|
$app['phraseanet.appbox']->set_data_to_cache($now, 'memcached_update_' . $sbas_id);
|
||||||
|
|
||||||
$conn = \connection::getPDOConnection();
|
$conn = \connection::getPDOConnection($app);
|
||||||
|
|
||||||
$sql = 'UPDATE sitepreff SET memcached_update = :date';
|
$sql = 'UPDATE sitepreff SET memcached_update = :date';
|
||||||
$stmt = $conn->prepare($sql);
|
$stmt = $conn->prepare($sql);
|
||||||
@@ -149,12 +151,12 @@ class cache_databox
|
|||||||
* @param mixed content $value
|
* @param mixed content $value
|
||||||
* @return Void
|
* @return Void
|
||||||
*/
|
*/
|
||||||
public static function update($sbas_id, $type, $value = '')
|
public static function update(Application $app, $sbas_id, $type, $value = '')
|
||||||
{
|
{
|
||||||
|
|
||||||
$connbas = \connection::getPDOConnection($sbas_id);
|
$connbas = \connection::getPDOConnection($app, $sbas_id);
|
||||||
|
|
||||||
$registry = \registry::get_instance();
|
$registry = $app['phraseanet.registry'];
|
||||||
|
|
||||||
$sql = 'SELECT distinct site_id as site_id
|
$sql = 'SELECT distinct site_id as site_id
|
||||||
FROM clients
|
FROM clients
|
||||||
@@ -179,11 +181,11 @@ class cache_databox
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function insertClient(\databox $databox)
|
public static function insertClient(Application $app, \databox $databox)
|
||||||
{
|
{
|
||||||
$connbas = $databox->get_connection();
|
$connbas = $databox->get_connection();
|
||||||
|
|
||||||
$registry = \registry::get_instance();
|
$registry = $app['phraseanet.registry'];
|
||||||
|
|
||||||
$sql = 'SELECT site_id FROM clients WHERE site_id = :site_id';
|
$sql = 'SELECT site_id FROM clients WHERE site_id = :site_id';
|
||||||
$stmt = $connbas->prepare($sql);
|
$stmt = $connbas->prepare($sql);
|
||||||
|
Reference in New Issue
Block a user