ver. 0.282: Banners frontend migration, Cache cleanup, Shared\Cache namespace
- Banners frontend: front\Views\Banners (new), BannerRepository +2 frontend methods, front\view\Site przepięty, usunięte front\factory\Banners i front\view\Banners - Cache cleanup: eliminacja legacy class.Cache.php (file-based cache), 13 metod front\factory przepiętych z \Cache::fetch/store na CacheHandler - Shared\Cache namespace: CacheHandler i RedisConnection przeniesione do Shared\Cache\, 60 odwołań CacheHandler i 12 odwołań RedisConnection przepiętych, usunięte backward-compat wrappery class.CacheHandler.php i class.RedisConnection.php - Naprawione rozbieżności kluczy cache (random_products, category_name) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,73 +0,0 @@
|
||||
<?php
|
||||
namespace front\factory;
|
||||
|
||||
class Banners
|
||||
{
|
||||
public static function banners()
|
||||
{
|
||||
global $mdb, $lang;
|
||||
|
||||
$cacheHandler = new \CacheHandler();
|
||||
$cacheKey = "\front\factory\Banners::banners";
|
||||
|
||||
$objectData = $cacheHandler->get($cacheKey);
|
||||
|
||||
if ( !$objectData )
|
||||
{
|
||||
$results = $mdb -> query( 'SELECT id, name FROM pp_banners WHERE status = 1 AND ( date_start <= \'' . date( 'Y-m-d' ) . '\' OR date_start IS NULL ) AND ( date_end >= \'' . date( 'Y-m-d' ) . '\' OR date_end IS NULL ) AND home_page = 0' ) -> fetchAll();
|
||||
if ( is_array( $results ) and !empty( $results ) ) foreach ( $results as $row )
|
||||
{
|
||||
$row['languages'] = $mdb -> get( 'pp_banners_langs', '*', [ 'AND' => [ 'id_banner' => (int)$row['id'], 'id_lang' => $lang[0] ] ] );
|
||||
$banners[] = $row;
|
||||
}
|
||||
|
||||
$cacheHandler -> set( $cacheKey, $banners );
|
||||
}
|
||||
else
|
||||
{
|
||||
return unserialize($objectData);
|
||||
}
|
||||
|
||||
return $banners;
|
||||
}
|
||||
|
||||
public static function main_banner()
|
||||
{
|
||||
global $mdb, $lang_id;
|
||||
|
||||
$cacheHandler = new \CacheHandler();
|
||||
$cacheKey = "\front\factory\Banners::main_banner:$lang_id";
|
||||
|
||||
$objectData = $cacheHandler -> get( $cacheKey );
|
||||
|
||||
if ( !$objectData )
|
||||
{
|
||||
$banner = $mdb -> query( 'SELECT '
|
||||
. '* '
|
||||
. 'FROM '
|
||||
. 'pp_banners '
|
||||
. 'WHERE '
|
||||
. 'status = 1 '
|
||||
. 'AND '
|
||||
. '( date_start <= \'' . date( 'Y-m-d' ) . '\' OR date_start IS NULL ) '
|
||||
. 'AND '
|
||||
. '( date_end >= \'' . date( 'Y-m-d' ) . '\' OR date_end IS NULL ) '
|
||||
. 'AND '
|
||||
. 'home_page = 1 '
|
||||
. 'ORDER BY '
|
||||
. 'date_end ASC '
|
||||
. 'LIMIT 1' ) -> fetchAll();
|
||||
$banner = $banner[0];
|
||||
if ( $banner )
|
||||
$banner['languages'] = $mdb -> get( 'pp_banners_langs', '*', [ 'AND' => [ 'id_banner' => (int)$banner['id'], 'id_lang' => $lang_id ] ] );
|
||||
|
||||
$cacheHandler -> set( $cacheKey, $banner );
|
||||
}
|
||||
else
|
||||
{
|
||||
return unserialize( $objectData );
|
||||
}
|
||||
|
||||
return $banner;
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@ class Layouts
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
$cacheHandler = new \CacheHandler();
|
||||
$cacheHandler = new \Shared\Cache\CacheHandler();
|
||||
$cacheKey = "\front\factory\Layouts::default_layout";
|
||||
|
||||
$objectData = $cacheHandler -> get( $cacheKey );
|
||||
@@ -35,7 +35,7 @@ class Layouts
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
$cacheHandler = new \CacheHandler();
|
||||
$cacheHandler = new \Shared\Cache\CacheHandler();
|
||||
$cacheKey = "\front\factory\Layouts::product_layout:$product_id";
|
||||
|
||||
$objectData = $cacheHandler -> get( $cacheKey );
|
||||
@@ -87,7 +87,7 @@ class Layouts
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
$cacheHandler = new \CacheHandler();
|
||||
$cacheHandler = new \Shared\Cache\CacheHandler();
|
||||
$cacheKey = "\front\factory\Layouts::article_layout:$article_id";
|
||||
|
||||
$objectData = $cacheHandler -> get( $cacheKey );
|
||||
@@ -110,7 +110,7 @@ class Layouts
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
$cacheHandler = new \CacheHandler();
|
||||
$cacheHandler = new \Shared\Cache\CacheHandler();
|
||||
$cacheKey = "\front\factory\Layouts::category_layout:$category_id";
|
||||
|
||||
$objectData = $cacheHandler -> get( $cacheKey );
|
||||
@@ -148,7 +148,7 @@ class Layouts
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
$cacheHandler = new \CacheHandler();
|
||||
$cacheHandler = new \Shared\Cache\CacheHandler();
|
||||
$cacheKey = "\front\factory\Layouts::active_layout:$page_id";
|
||||
|
||||
$objectData = $cacheHandler -> get( $cacheKey );
|
||||
|
||||
@@ -7,7 +7,7 @@ class Menu
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
$cacheHandler = new \CacheHandler();
|
||||
$cacheHandler = new \Shared\Cache\CacheHandler();
|
||||
$cacheKey = "\front\factory\Menu::menu_details:$menu_id";
|
||||
|
||||
$objectData = $cacheHandler -> get( $cacheKey );
|
||||
@@ -31,7 +31,7 @@ class Menu
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
$cacheHandler = new \CacheHandler();
|
||||
$cacheHandler = new \Shared\Cache\CacheHandler();
|
||||
$cacheKey = "\front\factory\Menu::menu_pages:$menu_id:$parent_id";
|
||||
|
||||
$objectData = $cacheHandler->get($cacheKey);
|
||||
|
||||
@@ -7,7 +7,7 @@ class Pages
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
$cacheHandler = new \CacheHandler();
|
||||
$cacheHandler = new \Shared\Cache\CacheHandler();
|
||||
$cacheKey = "\front\factory\Pages::page_sort:$page_id";
|
||||
|
||||
$objectData = $cacheHandler -> get( $cacheKey );
|
||||
@@ -48,7 +48,7 @@ class Pages
|
||||
if ( $lang_tmp )
|
||||
$lang_id = $lang_tmp;
|
||||
|
||||
$cacheHandler = new \CacheHandler();
|
||||
$cacheHandler = new \Shared\Cache\CacheHandler();
|
||||
$cacheKey = "\front\factory\Pages::page_details:$id:$lang_id";
|
||||
|
||||
$objectData = $cacheHandler->get($cacheKey);
|
||||
@@ -69,7 +69,7 @@ class Pages
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
$cacheHandler = new \CacheHandler();
|
||||
$cacheHandler = new \Shared\Cache\CacheHandler();
|
||||
$cacheKey = "\front\factory\Pages::main_page_id";
|
||||
|
||||
$objectData = $cacheHandler->get($cacheKey);
|
||||
|
||||
@@ -7,7 +7,7 @@ class Scontainers
|
||||
{
|
||||
global $mdb, $lang;
|
||||
|
||||
$cacheHandler = new \CacheHandler();
|
||||
$cacheHandler = new \Shared\Cache\CacheHandler();
|
||||
$cacheKey = "\front\factory\Scontainers::scontainer_details:$scontainer_id";
|
||||
|
||||
$objectData = $cacheHandler->get($cacheKey);
|
||||
|
||||
@@ -7,7 +7,7 @@ class ShopAttribute
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
$cacheHandler = new \CacheHandler();
|
||||
$cacheHandler = new \Shared\Cache\CacheHandler();
|
||||
$cacheKey = "\front\factory\ShopAttribute::value_details:$value_id:$lang_id";
|
||||
|
||||
$objectData = $cacheHandler -> get( $cacheKey );
|
||||
@@ -31,12 +31,20 @@ class ShopAttribute
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
if ( !$attribute = \Cache::fetch( 'attribute_details_' . $attribute_id . '_' . $lang_id ) )
|
||||
$cacheHandler = new \Shared\Cache\CacheHandler();
|
||||
$cacheKey = 'attribute_details_' . $attribute_id . '_' . $lang_id;
|
||||
$objectData = $cacheHandler->get( $cacheKey );
|
||||
|
||||
if ( !$objectData )
|
||||
{
|
||||
$attribute = $mdb -> get( 'pp_shop_attributes', '*', [ 'id' => (int)$attribute_id ] );
|
||||
$attribute['language'] = $mdb -> get( 'pp_shop_attributes_langs', [ 'lang_id', 'name' ], [ 'AND' => [ 'attribute_id' => (int)$attribute_id, 'lang_id' => $lang_id ] ] );
|
||||
|
||||
\Cache::store( 'attribute_details_' . $attribute_id . '_' . $lang_id, $attribute );
|
||||
$cacheHandler->set( $cacheKey, $attribute );
|
||||
}
|
||||
else
|
||||
{
|
||||
return unserialize( $objectData );
|
||||
}
|
||||
return $attribute;
|
||||
}
|
||||
|
||||
@@ -6,10 +6,18 @@ class ShopCategory
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
if ( !$category_sort = \Cache::fetch( "get_category_sort:$category_id" ) )
|
||||
$cacheHandler = new \Shared\Cache\CacheHandler();
|
||||
$cacheKey = "get_category_sort:$category_id";
|
||||
$objectData = $cacheHandler->get( $cacheKey );
|
||||
|
||||
if ( !$objectData )
|
||||
{
|
||||
$category_sort = $mdb -> get( 'pp_shop_categories', 'sort_type', [ 'id' => $category_id ] );
|
||||
\Cache::store( "get_category_sort:$category_id", $category_sort );
|
||||
$cacheHandler->set( $cacheKey, $category_sort );
|
||||
}
|
||||
else
|
||||
{
|
||||
return unserialize( $objectData );
|
||||
}
|
||||
|
||||
return $category_sort;
|
||||
@@ -19,11 +27,19 @@ class ShopCategory
|
||||
{
|
||||
global $mdb, $lang_id;
|
||||
|
||||
if ( !$category_name = \Cache::fetch( 'category_name' . $lang_id . '_' . $category_id . 'tmp' ) )
|
||||
$cacheHandler = new \Shared\Cache\CacheHandler();
|
||||
$cacheKey = 'category_name' . $lang_id . '_' . $category_id;
|
||||
$objectData = $cacheHandler->get( $cacheKey );
|
||||
|
||||
if ( !$objectData )
|
||||
{
|
||||
$category_name = $mdb -> get( 'pp_shop_categories_langs', 'title', [ 'AND' => [ 'category_id' => (int)$category_id, 'lang_id' => $lang_id ] ] );
|
||||
|
||||
\Cache::store( 'category_name' . $lang_id . '_' . $category_id, $category_name );
|
||||
$cacheHandler->set( $cacheKey, $category_name );
|
||||
}
|
||||
else
|
||||
{
|
||||
return unserialize( $objectData );
|
||||
}
|
||||
|
||||
return $category_name;
|
||||
@@ -45,7 +61,7 @@ class ShopCategory
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
$cacheHandler = new \CacheHandler();
|
||||
$cacheHandler = new \Shared\Cache\CacheHandler();
|
||||
$cacheKey = "\front\factory\ShopCategory::blog_category_products:$category_id:$lang_id:$limit";
|
||||
|
||||
$objectData = $cacheHandler -> get( $cacheKey );
|
||||
@@ -95,7 +111,7 @@ class ShopCategory
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
$cacheHandler = new \CacheHandler();
|
||||
$cacheHandler = new \Shared\Cache\CacheHandler();
|
||||
$cacheKey = "\front\factory\ShopCategory::category_products_count:$category_id:$lang_id";
|
||||
|
||||
$objectData = $cacheHandler -> get( $cacheKey );
|
||||
@@ -166,7 +182,7 @@ class ShopCategory
|
||||
break;
|
||||
endswitch;
|
||||
|
||||
$cacheHandler = new \CacheHandler();
|
||||
$cacheHandler = new \Shared\Cache\CacheHandler();
|
||||
$cacheKey = "\front\factory\ShopCategory::products_id:$category_id:$sort_type:$lang_id:$products_limit:$from:$order";
|
||||
|
||||
$objectData = $cacheHandler -> get( $cacheKey );
|
||||
@@ -245,7 +261,7 @@ class ShopCategory
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
$cacheHandler = new \CacheHandler();
|
||||
$cacheHandler = new \Shared\Cache\CacheHandler();
|
||||
$cacheKey = "\front\factory\ShopCategory::categories_details:$parent_id";
|
||||
|
||||
$objectData = $cacheHandler->get($cacheKey);
|
||||
@@ -275,7 +291,7 @@ class ShopCategory
|
||||
{
|
||||
global $mdb, $lang_id;
|
||||
|
||||
$cacheHandler = new \CacheHandler();
|
||||
$cacheHandler = new \Shared\Cache\CacheHandler();
|
||||
$cacheKey = "\front\factory\ShopCategory::category_details:$category_id";
|
||||
|
||||
$objectData = $cacheHandler->get($cacheKey);
|
||||
|
||||
@@ -17,15 +17,16 @@ class ShopPaymentMethod
|
||||
public static function payment_methods_by_transport( $transport_method_id )
|
||||
{
|
||||
$transport_method_id = (int)$transport_method_id;
|
||||
$cacheHandler = new \Shared\Cache\CacheHandler();
|
||||
$cacheKey = 'payment_methods_by_transport' . $transport_method_id;
|
||||
$payments = \Cache::fetch( $cacheKey );
|
||||
$objectData = $cacheHandler->get( $cacheKey );
|
||||
|
||||
if ( $payments !== false && is_array( $payments ) ) {
|
||||
return $payments;
|
||||
if ( $objectData ) {
|
||||
return unserialize( $objectData );
|
||||
}
|
||||
|
||||
$payments = self::repo()->forTransport( $transport_method_id );
|
||||
\Cache::store( $cacheKey, $payments );
|
||||
$cacheHandler->set( $cacheKey, $payments );
|
||||
|
||||
return $payments;
|
||||
}
|
||||
@@ -38,12 +39,18 @@ class ShopPaymentMethod
|
||||
public static function payment_method( $payment_method_id )
|
||||
{
|
||||
$payment_method_id = (int)$payment_method_id;
|
||||
$cacheHandler = new \Shared\Cache\CacheHandler();
|
||||
$cacheKey = 'payment_method' . $payment_method_id;
|
||||
$payment_method = \Cache::fetch( $cacheKey );
|
||||
$objectData = $cacheHandler->get( $cacheKey );
|
||||
|
||||
if ( $payment_method === false ) {
|
||||
if ( !$objectData )
|
||||
{
|
||||
$payment_method = self::repo()->findActiveById( $payment_method_id );
|
||||
\Cache::store( $cacheKey, $payment_method );
|
||||
$cacheHandler->set( $cacheKey, $payment_method );
|
||||
}
|
||||
else
|
||||
{
|
||||
return unserialize( $objectData );
|
||||
}
|
||||
|
||||
return $payment_method;
|
||||
@@ -51,15 +58,16 @@ class ShopPaymentMethod
|
||||
|
||||
public static function payment_methods()
|
||||
{
|
||||
$cacheHandler = new \Shared\Cache\CacheHandler();
|
||||
$cacheKey = 'payment_methods';
|
||||
$payment_methods = \Cache::fetch( $cacheKey );
|
||||
$objectData = $cacheHandler->get( $cacheKey );
|
||||
|
||||
if ( $payment_methods !== false && is_array( $payment_methods ) ) {
|
||||
return $payment_methods;
|
||||
if ( $objectData ) {
|
||||
return unserialize( $objectData );
|
||||
}
|
||||
|
||||
$payment_methods = self::repo()->allActive();
|
||||
\Cache::store( $cacheKey, $payment_methods );
|
||||
$cacheHandler->set( $cacheKey, $payment_methods );
|
||||
|
||||
return $payment_methods;
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ class ShopProduct
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
$cacheHandler = new \CacheHandler();
|
||||
$cacheHandler = new \Shared\Cache\CacheHandler();
|
||||
$cacheKey = "\front\factory\ShopProduct::is_product_active:$product_id";
|
||||
|
||||
$objectData = $cacheHandler -> get( $cacheKey );
|
||||
@@ -85,10 +85,18 @@ class ShopProduct
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
if ( !$price = \Cache::fetch( 'get_minimal_price:' . $id_product ) )
|
||||
$cacheHandler = new \Shared\Cache\CacheHandler();
|
||||
$cacheKey = 'get_minimal_price:' . $id_product;
|
||||
$objectData = $cacheHandler->get( $cacheKey );
|
||||
|
||||
if ( !$objectData )
|
||||
{
|
||||
$price = $mdb -> min( 'pp_shop_product_price_history', 'price', [ 'AND' => [ 'id_product' => $id_product, 'price[!]' => str_replace( ',', '.', $price_brutto_promo ) ] ] );
|
||||
\Cache::store( 'get_minimal_price:' . $id_product, $price );
|
||||
$cacheHandler->set( $cacheKey, $price );
|
||||
}
|
||||
else
|
||||
{
|
||||
return unserialize( $objectData );
|
||||
}
|
||||
|
||||
return $price;
|
||||
@@ -108,11 +116,19 @@ class ShopProduct
|
||||
{
|
||||
global $mdb, $lang_id;
|
||||
|
||||
if ( !$product_name = \Cache::fetch( 'product_name' . $lang_id . '_' . $product_id ) )
|
||||
$cacheHandler = new \Shared\Cache\CacheHandler();
|
||||
$cacheKey = 'product_name' . $lang_id . '_' . $product_id;
|
||||
$objectData = $cacheHandler->get( $cacheKey );
|
||||
|
||||
if ( !$objectData )
|
||||
{
|
||||
$product_name = $mdb -> get( 'pp_shop_products_langs', 'name', [ 'AND' => [ 'product_id' => (int)$product_id, 'lang_id' => $lang_id ] ] );
|
||||
|
||||
\Cache::store( 'product_name' . $lang_id . '_' . $product_id, $product_name );
|
||||
$cacheHandler->set( $cacheKey, $product_name );
|
||||
}
|
||||
else
|
||||
{
|
||||
return unserialize( $objectData );
|
||||
}
|
||||
|
||||
return $product_name;
|
||||
@@ -122,12 +138,20 @@ class ShopProduct
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
if ( !$product_image = \Cache::fetch( 'product_image:' . $product_id ) )
|
||||
$cacheHandler = new \Shared\Cache\CacheHandler();
|
||||
$cacheKey = 'product_image:' . $product_id;
|
||||
$objectData = $cacheHandler->get( $cacheKey );
|
||||
|
||||
if ( !$objectData )
|
||||
{
|
||||
$results = $mdb -> query( 'SELECT src FROM pp_shop_products_images WHERE product_id = :product_id ORDER BY o ASC LIMIT 1', [ ':product_id' => (int)$product_id ] ) -> fetchAll( \PDO::FETCH_ASSOC );
|
||||
$product_image = $results[ 0 ][ 'src' ];
|
||||
|
||||
\Cache::store( 'product_image:' . $product_id, $product_image );
|
||||
$cacheHandler->set( $cacheKey, $product_image );
|
||||
}
|
||||
else
|
||||
{
|
||||
return unserialize( $objectData );
|
||||
}
|
||||
|
||||
return $product_image;
|
||||
@@ -137,7 +161,7 @@ class ShopProduct
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
$cacheHandler = new \CacheHandler();
|
||||
$cacheHandler = new \Shared\Cache\CacheHandler();
|
||||
$cacheKey = "\front\factory\ShopProduct::product_wp:$product_id";
|
||||
|
||||
$objectData = $cacheHandler -> get( $cacheKey );
|
||||
@@ -159,14 +183,22 @@ class ShopProduct
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
if ( !$products = \Cache::fetch( 'random_productsa_' . $product_id . '_' . $lang_id ) )
|
||||
$cacheHandler = new \Shared\Cache\CacheHandler();
|
||||
$cacheKey = 'random_products_' . $product_id . '_' . $lang_id;
|
||||
$objectData = $cacheHandler->get( $cacheKey );
|
||||
|
||||
if ( !$objectData )
|
||||
{
|
||||
$results = $mdb -> query( 'SELECT id FROM pp_shop_products WHERE status = 1 ORDER BY RAND() LIMIT 6' ) -> fetchAll();
|
||||
if ( is_array( $results ) and!empty( $results ) )
|
||||
foreach ( $results as $row )
|
||||
$products[] = \front\factory\ShopProduct::product_details( $row[ 'id' ], $lang_id );
|
||||
|
||||
\Cache::store( 'random_products_' . $product_id . '_' . $lang_id, $products );
|
||||
$cacheHandler->set( $cacheKey, $products );
|
||||
}
|
||||
else
|
||||
{
|
||||
return unserialize( $objectData );
|
||||
}
|
||||
|
||||
return $products;
|
||||
@@ -176,14 +208,22 @@ class ShopProduct
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
if ( !$products = \Cache::fetch( "promoted_products-$limit" ) )
|
||||
$cacheHandler = new \Shared\Cache\CacheHandler();
|
||||
$cacheKey = "promoted_products-$limit";
|
||||
$objectData = $cacheHandler->get( $cacheKey );
|
||||
|
||||
if ( !$objectData )
|
||||
{
|
||||
$results = $mdb -> query( 'SELECT id FROM pp_shop_products WHERE status = 1 AND promoted = 1 ORDER BY RAND() LIMIT ' . $limit ) -> fetchAll();
|
||||
if ( is_array( $results ) and!empty( $results ) )
|
||||
foreach ( $results as $row )
|
||||
$products[] = $row[ 'id' ];
|
||||
|
||||
\Cache::store( "promoted_products-$limit", $products );
|
||||
$cacheHandler->set( $cacheKey, $products );
|
||||
}
|
||||
else
|
||||
{
|
||||
return unserialize( $objectData );
|
||||
}
|
||||
|
||||
return $products;
|
||||
@@ -227,7 +267,7 @@ class ShopProduct
|
||||
if ( !$product_id )
|
||||
return false;
|
||||
|
||||
$cacheHandler = new \CacheHandler();
|
||||
$cacheHandler = new \Shared\Cache\CacheHandler();
|
||||
$cacheKey = "\front\factory\ShopProduct::product_details:$product_id:$lang_id";
|
||||
|
||||
$objectData = $cacheHandler->get($cacheKey);
|
||||
|
||||
@@ -13,7 +13,7 @@ class ShopTransport
|
||||
{
|
||||
global $mdb, $settings;
|
||||
|
||||
$cacheHandler = new \CacheHandler();
|
||||
$cacheHandler = new \Shared\Cache\CacheHandler();
|
||||
$cacheKey = "\front\factory\ShopTransport::transport_methods";
|
||||
|
||||
$objectData = $cacheHandler -> get( $cacheKey );
|
||||
@@ -57,12 +57,20 @@ class ShopTransport
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
if ( !$cost = \Cache::fetch( 'transport_cost_' . $transport_id ) )
|
||||
$cacheHandler = new \Shared\Cache\CacheHandler();
|
||||
$cacheKey = 'transport_cost_' . $transport_id;
|
||||
$objectData = $cacheHandler->get( $cacheKey );
|
||||
|
||||
if ( !$objectData )
|
||||
{
|
||||
$repo = new \Domain\Transport\TransportRepository($mdb);
|
||||
$cost = $repo->getTransportCost($transport_id);
|
||||
|
||||
\Cache::store( 'transport_cost_' . $transport_id, $cost );
|
||||
$cacheHandler->set( $cacheKey, $cost );
|
||||
}
|
||||
else
|
||||
{
|
||||
return unserialize( $objectData );
|
||||
}
|
||||
return $cost;
|
||||
}
|
||||
@@ -71,12 +79,20 @@ class ShopTransport
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
if ( !$transport = \Cache::fetch( 'transport' . $transport_id ) )
|
||||
$cacheHandler = new \Shared\Cache\CacheHandler();
|
||||
$cacheKey = 'transport' . $transport_id;
|
||||
$objectData = $cacheHandler->get( $cacheKey );
|
||||
|
||||
if ( !$objectData )
|
||||
{
|
||||
$repo = new \Domain\Transport\TransportRepository($mdb);
|
||||
$transport = $repo->findActiveById($transport_id);
|
||||
|
||||
\Cache::store( 'transport' . $transport_id, $transport );
|
||||
$cacheHandler->set( $cacheKey, $transport );
|
||||
}
|
||||
else
|
||||
{
|
||||
return unserialize( $objectData );
|
||||
}
|
||||
return $transport;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user