delete cache item when updating

This commit is contained in:
Daniel Maya 2019-06-19 18:00:53 +02:00
parent 649689b1a1
commit ac8efd2bef
1 changed files with 10 additions and 2 deletions

View File

@ -1635,7 +1635,7 @@ class Item extends CachedModel
$dataModelEncode = $this->encode($this->toArray()); $dataModelEncode = $this->encode($this->toArray());
$dataEncode = $this->encode($data); $dataEncode = $this->encode($data);
hd(self::toArray(), true);
$save = \array_merge($dataModelEncode, $dataEncode); $save = \array_merge($dataModelEncode, $dataEncode);
if (!empty($save)) { if (!empty($save)) {
@ -1648,7 +1648,15 @@ class Item extends CachedModel
} else { } else {
// Update. // Update.
$result = \db_process_sql_update('tlayout_data', $save, ['id' => $save['id']]); $result = \db_process_sql_update('tlayout_data', $save, ['id' => $save['id']]);
if ($result) { // Invalidate the item's cache.
if ($result !== false && $result > 0) {
db_process_sql_delete(
'tvisual_console_elements_cache',
[
'vc_item_id' => (int) $save['id'],
]
);
$item = static::fromDB(['id' => $save['id']]); $item = static::fromDB(['id' => $save['id']]);
// Update the model. // Update the model.
if (!empty($item)) { if (!empty($item)) {