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

CMemCache stop working after upgrade to 1.1.11 because of wrong expire time #1066

Closed
SonicGD opened this issue Jul 30, 2012 · 7 comments · Fixed by #1115
Closed

CMemCache stop working after upgrade to 1.1.11 because of wrong expire time #1066

SonicGD opened this issue Jul 30, 2012 · 7 comments · Fixed by #1115
Assignees
Labels

Comments

@SonicGD
Copy link

SonicGD commented Jul 30, 2012

After upgrade to 1.1.11 i notice that all my cache not working so i even can't login into my app because i use CCacheHttpSession. After some investigation i detected, that problem have place because this code was deleted:

if ($expire > 0)
            $expire += time();
        else
            $expire = 0;

from setValue and addValue methods of CMemCache. So session data saves with expiration time in past:

return $this->_cache->set($this->calculateKey($id),$data,$this->getTimeout()); //my session.gc_maxlifetime is 14400

I returned this "time shifting" code back and all work as it should.

@mdomba
Copy link
Member

mdomba commented Jul 30, 2012

This was removed in #919 by @resurtm with the commit b532414

@resurtm
Copy link
Contributor

resurtm commented Jul 30, 2012

According to the PHP manual it should not become broken: http://www.php.net/manual/en/memcached.expiration.php

Quote:

In all such cases, the actual value sent may either be Unix time (number of seconds since January 1, 1970, as an integer), or a number of seconds starting from current time. In the latter case, this number of seconds may not exceed 60_60_24*30 (number of seconds in 30 days); if the expiration value is larger than that, the server will consider it to be real Unix time value rather than an offset from current time.

If the expiration value is 0 (the default), the item never expires (although it may be deleted from the server to make place for other items).

Investigating this.

@resurtm
Copy link
Contributor

resurtm commented Jul 30, 2012

@SonicGD Could you please explain what value you're passing to the cache application component?

return $this->_cache->set($this->calculateKey($id),$data,$this->getTimeout()); //my session.gc_maxlifetime is 14400

What is the exact value returned by $this->getTimeout()? Try to debug it someway.

Btw, testing myself.

@SonicGD
Copy link
Author

SonicGD commented Jul 30, 2012

Yeah, problem in timeout. In main.php config session timeout is 31536000. So as when i do

var_dump($this->getTimeout());

So it applies as unixts. I just need to reduce it. But this is kind of undefined behavior. Maybe setValue shoud check for expire range? Or just mention it here - http://www.yiiframework.com/doc/api/1.1/CCacheHttpSession/ or here - http://www.yiiframework.com/doc/api/1.1/CMemCache/?

@resurtm
Copy link
Contributor

resurtm commented Jul 30, 2012

@SonicGD Yes, now i understand the problem.

A note to be even more clear for other people reading this issue: your value is 31536000, max possible value is 2592000 (according to the PHP manual). Therefore memcache treats your value as absolute UNIX timestamp (of course 31536000 is less than current timestamp), not the difference (delta time) in seconds as you want.

@samdark @mdomba I don't think this is a very critical issue thus we can fix it in 1.1.12. Fixing and refinement PR will be ready soon.

@mdomba
Copy link
Member

mdomba commented Jul 30, 2012

Seems not critical but many users can be affected if they have the expiration time > 30 days.

For now I will open a Yii 1.1.11 known issues on the Yii forum -> anouncements so other users get noticed about this

@samdark
Copy link
Member

samdark commented Jul 30, 2012

We can mention it in release announcement as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
4 participants