Clearing product price cache

1 month ago
How can i clear product price ?
I created a Schedule task and on exectue i added
_staticCacheManager.RemoveByPrefix("Nop.totals.productprice");

but its not gonna work, what should i do ?

Thank you.
NopCommerce 4.30 Verison.
1 month ago
Could anyone help me ?

On 3.70 i used RemoveByPattern
1 month ago
see how it's done here: https://github.com/nopSolutions/nopCommerce/blob/4.30-bug-fixes/src/Libraries/Nop.Services/Catalog/Caching/ProductCacheEventConsumer.cs
1 month ago
af1racing wrote:

Thanks for helping but theese cache are for product i mean, key per product,
i need to clear all cache prices i mean cache from all products.
1 month ago
using Nop.Core.Domain.Catalog;
using Nop.Core.Caching;
using Nop.Services.Caching;
using Nop.Services.Orders;
using Nop.Services.Tasks;
using Nop.Services.Logging;
using Nop.Services.Catalog;

namespace Nop.Services.Caching
{
    /// <summary>
    /// Clear cache scheduled task implementation
    /// </summary>
    public partial class ClearCacheTaskGenelec : IScheduleTask
    {
        #region Fields

        private readonly IStaticCacheManager _staticCacheManager;
        private readonly ILogger _logger;
        private readonly ICacheKeyService _cacheKeyService;

        #endregion

        #region Ctor

        public ClearCacheTaskGenelec(IStaticCacheManager staticCacheManager,
            ILogger logger,
            ICacheKeyService cacheKeyService)
        {
            _staticCacheManager = staticCacheManager;
            _logger = logger;
            _cacheKeyService = cacheKeyService;
        }

        #endregion

        #region Methods

        /// <summary>
        /// Executes a task
        /// </summary>
        public void Execute()
        {
            //var cacheKey = _cacheKeyService.PrepareKey(NopCatalogDefaults.ProductTierPricesCacheKey);
            //var cacheKey = _cacheKeyService.PrepareKey(NopCatalogDefaults.ProductsByIdsCacheKey);
            //_staticCacheManager.Remove(cacheKey);

            //var prefix = _cacheKeyService.PrepareKeyPrefix(NopCatalogDefaults.ProductPricePrefixCacheKey);
            //_staticCacheManager.RemoveByPrefix(prefix);
            _staticCacheManager.RemoveByPrefix("Nop.totals.productprice-");
            _logger.Information("Izvrseno");
        }

        #endregion
    }
}


This is my code, i tried everything in comment but nothing happend.

So i Edit the price via SQL Studio after that i need to run this task to get edited price on product page.
1 month ago
so none could help me?
1 month ago
try Settings > Catalog Settings > disable "Cache product prices"
1 month ago
What about In the program you call                
_cacheManager.Clear();
which is the same function as on the Dashoard
1 month ago
Yidna wrote:
What about In the program you call                
_cacheManager.Clear();
which is the same function as on the Dashoard


That's cleaning my whole cache and what's the point of caching then ?

I need to clear product price cache every 20mins...
1 month ago
af1racing wrote:
try Settings > Catalog Settings > disable "Cache product prices"


tried and it chaning price on homepage & catalogs, but old price is on product page