Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F803878
D449.id1156.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Wed, Feb 26, 9:00 AM
Size
2 KB
Mime Type
text/x-diff
Expires
Thu, Feb 27, 9:00 AM (10 h, 38 m)
Engine
blob
Format
Raw Data
Handle
576601
Attached To
D449: MINC-200 - Cache results of the "ShippingQuoteEngine::initProperties" method
D449.id1156.diff
View Options
Index: modules/in-commerce/units/shipping_quote_engines/shipping_quote_engine.php
===================================================================
--- modules/in-commerce/units/shipping_quote_engines/shipping_quote_engine.php
+++ modules/in-commerce/units/shipping_quote_engines/shipping_quote_engine.php
@@ -187,23 +187,40 @@
/**
* Loads properties of shipping quote engine
*
+ * @return void
*/
- function initProperties()
+ protected function initProperties()
{
- $sql = 'SELECT Properties, FlatSurcharge, PercentSurcharge
- FROM ' . $this->Application->getUnitOption('sqe', 'TableName') . '
- WHERE LOWER(ClassName) = ' . $this->Conn->qstr( strtolower( get_class($this) ) );
- $data = $this->Conn->GetRow($sql);
-
- if (is_array($data)) {
- $properties = $data['Properties'] ? unserialize($data['Properties']) : Array ();
- $properties['FlatSurcharge'] = $data['FlatSurcharge'];
- $properties['PercentSurcharge'] = $data['PercentSurcharge'];
+ $cache_key = 'shipping_quote_engines_data[%SqeSerial%]';
+ $cache_value = $this->Application->getCache($cache_key);
- $this->properties = $properties;
+ if ( $cache_value === false ) {
+ $this->Conn->nextQueryCachable = true;
+ $sql = 'SELECT Properties, FlatSurcharge, PercentSurcharge, LOWER(ClassName) AS SQEKey
+ FROM ' . $this->Application->getUnitOption('sqe', 'TableName') . '
+ WHERE Status = ' . STATUS_ACTIVE;
+ $cache_value = $this->Conn->Query($sql, 'SQEKey');
+
+ foreach ( $cache_value as $sqe_key => $sqe_data ) {
+ $properties = $sqe_data['Properties'] ? unserialize($sqe_data['Properties']) : array();
+ $properties['FlatSurcharge'] = $sqe_data['FlatSurcharge'];
+ $properties['PercentSurcharge'] = $sqe_data['PercentSurcharge'];
+
+ $cache_value[$sqe_key]['Properties'] = $properties;
+ unset($cache_value[$sqe_key]['FlatSurcharge'], $cache_value[$sqe_key]['PercentSurcharge']);
+ }
+
+ $this->Application->setCache($cache_key, $cache_value);
+ }
+
+ $sqe_key = strtolower(get_class($this));
+
+ if ( array_key_exists($sqe_key, $cache_value) ) {
+ $this->properties = $cache_value[$sqe_key]['Properties'];
}
else {
- $this->properties = Array ();
+ $this->properties = array();
}
}
-}
\ No newline at end of file
+
+}
Event Timeline
Log In to Comment