使用PHP在memcache中存储数组,数组元素在一段时间后从memcache中取消设置

时间:2012-05-29 09:06:46

标签: php arrays memcached

我在memcache键'getBannerInfo'中保存了一个包含29个元素的数组。数组类似于:

[bannerid] => 5059
[campaignid] => 2687
[contenttype] => png
[storagetype] => url
[filename] => 
[imageurl] => http://testanalyst.org/c2687/13381938962791_50x50.png
[htmltemplate] => 
[htmlcache] => 
[append] => 
[width] => 50
[height] => 50
[weight] => 1
[url] => http://www.google.com
[alt] => new image
[bannertext] => New image
[description] => test image alt text 23
[autohtml] => f
[alt_contenttype] => 
[comments] => 
[status] => 0
[compiledlimitation] => xyz
[acl_plugins] => lmn
[acls_updated] => 2012-05-28 16:49:02
[parameters] => N;
[custom_data] => abc
[target] => 
[capping] => 0
[block] => 0
[is_deleted] => 0

现在,奇怪的是,我注意到,尽管最初它是按预期设置的,但是过了一段时间后,它从memcache键获取数据, alt key => val对在获取的数组中不存在。

我正在使用

 set($key,$arrayName,3600); and get($key)

的Memcache扩展类。

为什么会出现 alt 键,具体来说,这个键我最近添加到这个数组中,从那时起就注意到了这个问题。

1 个答案:

答案 0 :(得分:0)

缓存只是一个临时缓冲区,如果记录空间不足或记录已过期,它可以删除记录。这是预期的行为。如果您需要持久存储,请使用数据库。

相关问题