Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F727156
D449.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
Mon, Jan 6, 8:06 AM
Size
2 KB
Mime Type
text/x-diff
Expires
Tue, Jan 7, 8:06 AM (2 d, 23 h ago)
Engine
blob
Format
Raw Data
Handle
537209
Attached To
D449: MINC-200 - Cache results of the "ShippingQuoteEngine::initProperties" method
D449.diff
View Options
Index: branches/5.2.x/units/shipping_quote_engines/shipping_quote_engine.php
===================================================================
--- branches/5.2.x/units/shipping_quote_engines/shipping_quote_engine.php
+++ branches/5.2.x/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