Răsfoiți Sursa

#5176 Speed improvements: additional DB caches

Alex Trofimov 1 an în urmă
părinte
comite
435c9b7776

+ 4 - 3
inc/classes/BxDolFormQuery.php

@@ -217,10 +217,11 @@ class BxDolFormQuery extends BxDolDb
             $sUseValues = BX_DATA_VALUES_DEFAULT;
 
         $sQuery = $oDb->prepare("SELECT `Value`, `LKey`, `LKey2`, `Data` FROM `sys_form_pre_values` WHERE `Key` = ? ORDER BY `Order` ASC", $sKey);
-        if($sUseValues == BX_DATA_VALUES_ALL)
-            return $oDb->getAllWithKey($sQuery, 'Value');
+        if($sUseValues == BX_DATA_VALUES_ALL) {
+            return $oDb->fromCache('sys_form_pre_values_with_key_' . $sKey, 'getAllWithKey', $sQuery, 'Value');
+        }
 
-        $a = $oDb->getAll($sQuery);
+        $a = $oDb->fromCache('sys_form_pre_values_' . $sKey, 'getAll', $sQuery);
 
         $iMaxValue = 0;
         if ($isUseForSet)

+ 23 - 6
studio/template/scripts/BxBaseStudioFormsPreValues.php

@@ -190,11 +190,12 @@ class BxBaseStudioFormsPreValues extends BxDolStudioFormsPreValues
             }
 
             $iId = (int)$oForm->insert($aAdd);
-            if($iId != 0)
+            if($iId != 0) {
+                $this->onDataListChanged($oForm->getCleanValue('Key'));
                 $aRes = array('grid' => $this->getCode(false), 'blink' => $iId);
-            else
+            } else {
                 $aRes = array('msg' => _t('_adm_form_err_pre_values_create'));
-
+            }
             echoJson($aRes);
         }
         else {
@@ -377,11 +378,12 @@ class BxBaseStudioFormsPreValues extends BxDolStudioFormsPreValues
                 }
             }
 
-            if($oForm->update($aValue['id'], $aAdd) !== false)
+            if($oForm->update($aValue['id'], $aAdd) !== false) {
+                $this->onDataListChanged($this->sList);
                 $aRes = array('grid' => $this->getCode(false), 'blink' => $aValue['id']);
-            else
+            } else {
                 $aRes = array('msg' => _t('_adm_form_err_pre_values_edit'));
-
+            }
             echoJson($aRes);
         } 
         else {
@@ -396,6 +398,13 @@ class BxBaseStudioFormsPreValues extends BxDolStudioFormsPreValues
         }
     }
 
+    public function performActionReorder()
+    {        
+        $mixed = parent::performActionReorder();
+        $this->onDataListChanged($this->sList);
+        return $mixed;
+    }
+
     public function performActionDelete()
     {
         $sAction = 'delete';
@@ -419,6 +428,8 @@ class BxBaseStudioFormsPreValues extends BxDolStudioFormsPreValues
             if((int)$this->_delete($iId) <= 0)
                 continue;
 
+            $this->onDataListChanged($this->sList);
+
             $oLanguage->deleteLanguageString($aValue['lkey']);
             $oLanguage->deleteLanguageString($aValue['lkey2']);
 
@@ -562,6 +573,12 @@ class BxBaseStudioFormsPreValues extends BxDolStudioFormsPreValues
     {
         return is_numeric($mixedValue) && (int)$mixedValue >= 1 && (int)$mixedValue <= BX_DOL_STUDIO_FIELD_PRE_VALUE_INT_MAX;
     }
+
+    protected function onDataListChanged($sKey)
+    {
+        $this->oDb->cleanCache('sys_form_pre_values_with_key_' . $sKey);
+        $this->oDb->cleanCache('sys_form_pre_values_' . $sKey);
+    }
 }
 
 /** @} */