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:
2026-02-16 21:25:50 +01:00
parent fb81c54e06
commit 285cbe5515
54 changed files with 594 additions and 346 deletions

View File

@@ -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);