mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-11 12:03:14 +00:00
Cache more metadatas values
This commit is contained in:
@@ -183,6 +183,9 @@ class caption_Field_Value implements cache_cacheableInterface
|
|||||||
$stmt->execute(array(':id' => $this->id));
|
$stmt->execute(array(':id' => $this->id));
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
|
$this->delete_data_from_cache();
|
||||||
|
$this->databox_field->delete_data_from_cache();
|
||||||
|
|
||||||
$sbas_id = $this->record->get_sbas_id();
|
$sbas_id = $this->record->get_sbas_id();
|
||||||
$this->record->get_caption()->delete_data_from_cache();
|
$this->record->get_caption()->delete_data_from_cache();
|
||||||
|
|
||||||
@@ -224,6 +227,8 @@ class caption_Field_Value implements cache_cacheableInterface
|
|||||||
|
|
||||||
$this->VocabularyId = $this->VocabularyType = null;
|
$this->VocabularyId = $this->VocabularyType = null;
|
||||||
|
|
||||||
|
$this->delete_data_from_cache();
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -266,6 +271,8 @@ class caption_Field_Value implements cache_cacheableInterface
|
|||||||
$stmt_up->execute($params);
|
$stmt_up->execute($params);
|
||||||
$stmt_up->closeCursor();
|
$stmt_up->closeCursor();
|
||||||
|
|
||||||
|
$this->delete_data_from_cache();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$registry = registry::get_instance();
|
$registry = registry::get_instance();
|
||||||
$sphinx_rt = sphinxrt::get_instance($registry);
|
$sphinx_rt = sphinxrt::get_instance($registry);
|
||||||
@@ -399,6 +406,7 @@ class caption_Field_Value implements cache_cacheableInterface
|
|||||||
$caption_field_value->update_cache_value($value);
|
$caption_field_value->update_cache_value($value);
|
||||||
|
|
||||||
$record->get_caption()->delete_data_from_cache();
|
$record->get_caption()->delete_data_from_cache();
|
||||||
|
$this->databox_field->delete_data_from_cache();
|
||||||
|
|
||||||
return $caption_field_value;
|
return $caption_field_value;
|
||||||
}
|
}
|
||||||
|
@@ -15,7 +15,7 @@
|
|||||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||||
* @link www.phraseanet.com
|
* @link www.phraseanet.com
|
||||||
*/
|
*/
|
||||||
class caption_field
|
class caption_field implements cache_cacheableInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -48,21 +48,7 @@ class caption_field
|
|||||||
$this->databox_field = $databox_field;
|
$this->databox_field = $databox_field;
|
||||||
$this->values = array();
|
$this->values = array();
|
||||||
|
|
||||||
$connbas = $databox_field->get_connection();
|
$rs = $this->get_metadatas_ids();
|
||||||
|
|
||||||
$sql = 'SELECT id FROM metadatas
|
|
||||||
WHERE record_id = :record_id
|
|
||||||
AND meta_struct_id = :meta_struct_id';
|
|
||||||
|
|
||||||
$params = array(
|
|
||||||
':record_id' => $record->get_record_id()
|
|
||||||
, ':meta_struct_id' => $databox_field->get_id()
|
|
||||||
);
|
|
||||||
|
|
||||||
$stmt = $connbas->prepare($sql);
|
|
||||||
$stmt->execute($params);
|
|
||||||
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
||||||
$stmt->closeCursor();
|
|
||||||
|
|
||||||
foreach ($rs as $row) {
|
foreach ($rs as $row) {
|
||||||
$this->values[$row['id']] = new caption_Field_Value($databox_field, $record, $row['id']);
|
$this->values[$row['id']] = new caption_Field_Value($databox_field, $record, $row['id']);
|
||||||
@@ -78,6 +64,35 @@ class caption_field
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function get_metadatas_ids()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return $this->get_data_from_cache();
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$connbas = $this->databox_field->get_connection();
|
||||||
|
|
||||||
|
$sql = 'SELECT id FROM metadatas
|
||||||
|
WHERE record_id = :record_id
|
||||||
|
AND meta_struct_id = :meta_struct_id';
|
||||||
|
|
||||||
|
$params = array(
|
||||||
|
':record_id' => $this->record->get_record_id()
|
||||||
|
, ':meta_struct_id' => $this->databox_field->get_id()
|
||||||
|
);
|
||||||
|
|
||||||
|
$stmt = $connbas->prepare($sql);
|
||||||
|
$stmt->execute($params);
|
||||||
|
$ids = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
$stmt->closeCursor();
|
||||||
|
|
||||||
|
$this->set_data_to_cache($ids);
|
||||||
|
|
||||||
|
return $ids;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return record_adapter
|
* @return record_adapter
|
||||||
@@ -310,7 +325,7 @@ class caption_field
|
|||||||
$record->set_metadatas(array());
|
$record->set_metadatas(array());
|
||||||
unset($record);
|
unset($record);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -360,7 +375,7 @@ class caption_field
|
|||||||
|
|
||||||
unset($record);
|
unset($record);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@@ -430,7 +445,7 @@ class caption_field
|
|||||||
unset($caption_field);
|
unset($caption_field);
|
||||||
unset($record);
|
unset($record);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -439,4 +454,56 @@ class caption_field
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Part of the cache_cacheableInterface
|
||||||
|
*
|
||||||
|
* @param string $option
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function get_cache_key($option = null)
|
||||||
|
{
|
||||||
|
return 'caption_field_' . $this->record->get_serialize_key() . ($option ? '_' . $option : '');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Part of the cache_cacheableInterface
|
||||||
|
*
|
||||||
|
* @param string $option
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function get_data_from_cache($option = null)
|
||||||
|
{
|
||||||
|
$databox = $this->record->get_databox();
|
||||||
|
|
||||||
|
return $databox->get_data_from_cache($this->get_cache_key($option));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Part of the cache_cacheableInterface
|
||||||
|
*
|
||||||
|
* @param mixed $value
|
||||||
|
* @param string $option
|
||||||
|
* @param int $duration
|
||||||
|
* @return caption_field
|
||||||
|
*/
|
||||||
|
public function set_data_to_cache($value, $option = null, $duration = 360000)
|
||||||
|
{
|
||||||
|
$databox = $this->record->get_databox();
|
||||||
|
|
||||||
|
return $databox->set_data_to_cache($value, $this->get_cache_key($option), $duration);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Part of the cache_cacheableInterface
|
||||||
|
*
|
||||||
|
* @param string $option
|
||||||
|
* @return caption_field
|
||||||
|
*/
|
||||||
|
public function delete_data_from_cache($option = null)
|
||||||
|
{
|
||||||
|
$databox = $this->record->get_databox();
|
||||||
|
|
||||||
|
return $databox->delete_data_from_cache($this->get_cache_key($option));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user