prismicio-community / php-kit

Community maintained development kit for Prismic and the PHP language
https://prismic.io
Other
109 stars 83 forks source link

(apc "bug") Caching impossible on ubuntu precise #54

Closed barrycarton closed 10 years ago

barrycarton commented 10 years ago

Problem

Although it makes total sense to cache object forever, the native apc_store function returns false (not the problem - see below) when ttl is [50 years] - as it is the case when you consume the prismic api. Works perfectly well when ttl is [10 years]. This is not a bug but might be a very wispread standard issue nontheless.

Solution

Since it is a pure contingency I think it's a design decision and it is up to you to tell me how to circumvent this problem. As per official documentation It seems that setting the ttl to 0 would achieve the same result in a safer way :

TTL allocation takes place here : https://github.com/prismicio/php-kit/blob/master/src/Prismic/SearchForm.php#L259

barrycarton commented 10 years ago

I made a mistake. Past a certain ttl value apc stores the value "false" wahtever the value of the argument passed to the apc_store function. Therefore immutable object are not properly cached.

<?php
$bar = 'BAR';
var_dump(apc_store('foo', $bar,315360000));    // 10 years TTL - Stored value is 'BAR'
var_dump(apc_store('foo2', $bar,315360000*5)); // 50 years TTL - Stored value is false not 'BAR'

Does it make any sense?

barrycarton commented 10 years ago

screenshot of apc.php tool output

rudyrigot commented 10 years ago

Hi Barry,

I installed a VM with Ubuntu Precise this morning, and all the necessary stack to run our PHPunit tests (PHP5, composer, phpunit, ...), and I don't seem to reproduce an issue, even if I set the ttl to an excessively high value for each apc_store.

Can you give me a way to reproduce the issue, so that I can fix it? I guess indeed, setting the ttl to 0 past a certain value would be a good way to settle it.

Thanks a lot for taking the time to help us fix this.

barrycarton commented 10 years ago

I think #64 fixes it and the issue can be safely ignored since it appears to be ubuntu specific.