Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

APC Cache TTL not working #21945

Closed
DevSTG opened this issue Nov 17, 2020 · 14 comments
Closed

APC Cache TTL not working #21945

DevSTG opened this issue Nov 17, 2020 · 14 comments
Labels
1.7.6.8 Affects versions BO Category: Back Office Bug Type: Bug Can't reproduce Resolution: issue closed because cannot be reproduced Performance Label: Which BO under menu is concerned

Comments

@DevSTG
Copy link

DevSTG commented Nov 17, 2020

Describe the bug

I use CacheApc as my caching system.
No matter what $ttl value I set in $cache->set($cacheId, $result, $ttl) method cached result is stored for about a minute.
I wrote a module to test APC:

class Mymodule extends Module {
...
    public function hookDisplayTop() {
	$this->context->smarty->assign(array(
            'result' => self::testCacheTtl(),
	));
        return $this->display(__FILE__, 'views/templates/front/cache.tpl');
    }
	
   private static function testCacheTtl() {
	$ttl = 0;
        $cacheId = "testCacheTtl";
	$cache = Cache::getInstance();
        if (!$cache->exists($cacheId)) {
            $result = date("Y-m-d H:i");
	    $cache->set($cacheId, $result, $ttl);
            return $result;
        }
        return $cache->get($cacheId);
    }
}

and it always displays time value >= 1 minute past.
See: https://sukcesgroup.pl/sklepnowy/pl/kontakt
Here are my APC settings: https://sukcesgroup.pl/sklepnowy/apc.png

Expected behavior

APC storing values for given ttl value

Steps to Reproduce

Enable APC caching, try to store and restore some values

Screenshots

If applicable, add screenshots or screen recordings to help explain your problem.

Additional information

  • PrestaShop version: 1.7.6.8
  • PHP version: 5.6.38
@hibatallahAouadni
Copy link
Contributor

Hello @DevSTG

I set in $cache->set($cacheId, $result, $ttl)

Where excatly did you set the $ttl value, in which class or controller?

Thanks!

@hibatallahAouadni hibatallahAouadni added 1.7.6.8 Affects versions Bug Type: Bug NMI Status: issue needs more information Performance Label: Which BO under menu is concerned BO Category: Back Office labels Nov 17, 2020
@DevSTG
Copy link
Author

DevSTG commented Nov 17, 2020

I set $ttl value in my module class (see method Mymodule::testCacheTtl() in code that I included) and tried to display it using displayTop hook (hookDisplayTop() method above).
If I'm not mistaken Cache is a singleton, so it doesn't really matter when I use it ...

@hibatallahAouadni
Copy link
Contributor

Hello @DevSTG

As you can see in the screenshot below my APC settings:

image

And in my BO, I enabled the Use Cache option and choose CacheApc:

image

And as you explained to me I add the code in a module. And yet, I couldn't manage to reproduce your issue with PS1.7.6.8.
Could you please provide more info.

Thanks!

@DevSTG
Copy link
Author

DevSTG commented Nov 18, 2020

What additional info would you need?

@hibatallahAouadni
Copy link
Contributor

Ping @PrestaShop/prestashop-core-developers what do you think of this problem?

@hibatallahAouadni hibatallahAouadni added Waiting for dev Status: action required, waiting for tech feedback and removed NMI Status: issue needs more information labels Nov 18, 2020
@PierreRambaud
Copy link
Contributor

@hibatallahAouadni Are you able to reproduce, we need to be sure the problem come from the PrestaShop core and not the APC/APCU configuration :)

@PierreRambaud PierreRambaud removed the Waiting for dev Status: action required, waiting for tech feedback label Nov 18, 2020
@hibatallahAouadni
Copy link
Contributor

@PierreRambaud I didn't manage to reproduce the issue

@hibatallahAouadni hibatallahAouadni added the NMI Status: issue needs more information label Nov 18, 2020
@DevSTG
Copy link
Author

DevSTG commented Nov 20, 2020

@hibatallahAouadni did you try to reproduce th issue on PHP version: 5.6.x ?

@hibatallahAouadni hibatallahAouadni added TBR Status: issue to be reproduced and removed NMI Status: issue needs more information labels Nov 20, 2020
@PierreRambaud
Copy link
Contributor

@hibatallahAouadni did you try to reproduce th issue on PHP version: 5.6.x ?

We are not supporting PHP 5.6 anymore.

@DevSTG
Copy link
Author

DevSTG commented Nov 23, 2020

It's quite important news, I think I shouldn't be able to install PS if my PHP version is not supported.
Anyway, can you confirm PHP version affects APC cache?

@PierreRambaud
Copy link
Contributor

@DevNet Here's the PHP Compatibility Chart.
I'm not able to reproduce the problem with the latest PHP version. Unfortunately, we will not spend time testing all PrestaShop versions with old PHP versions if everything is working well on latest releases :)

@DevSTG
Copy link
Author

DevSTG commented Nov 23, 2020

@PierreRambaud The chart you provided suggests that my PS version 1.7.6.x seems to be ok with my PHP version 5.6.x, so maybe the chart should be updated?

@PierreRambaud
Copy link
Contributor

@PierreRambaud The chart you provided suggests that my PS version 1.7.6.x seems to be ok with my PHP version 5.6.x, so maybe the chart should be updated?

Not it is, but we are now working on 1.7.7.x and develop branches only. There will be no update on 1.7.6.x branch.

@hibatallahAouadni
Copy link
Contributor

Hello @DevSTG

Since we had no news from you for more than 20 days, I'll close this ticket to avoid cluttering up the backlog.
Please note that you can always create a new one if further information pops up.

Thanks!

@prestashop-issue-bot prestashop-issue-bot bot removed the TBR Status: issue to be reproduced label Dec 26, 2020
@hibatallahAouadni hibatallahAouadni added the Can't reproduce Resolution: issue closed because cannot be reproduced label Dec 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.7.6.8 Affects versions BO Category: Back Office Bug Type: Bug Can't reproduce Resolution: issue closed because cannot be reproduced Performance Label: Which BO under menu is concerned
Projects
None yet
Development

No branches or pull requests

3 participants