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


Storing Array in memcache using PHP , array element gets unset after sometime from memcache

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

[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)

的内存缓存扩展类。

为什么会发生这种情况 alt 键 特别是 ,我最近将此键添加到此数组中,从那时起就注意到了这个问题。

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