【问题标题】:Memcache expiration timesMemcache 过期时间
【发布时间】:2010-12-23 04:04:23
【问题描述】:

是否可以获得内存缓存中存储的值的剩余时间?

【问题讨论】:

    标签: memcached


    【解决方案1】:

    没有。 Memcache 过期时间只是出于礼貌而非保证。缓存中的任何项目都可能随时被清除。

    【讨论】:

      【解决方案2】:

      不,不是。如果你想要这样的东西,你需要把它编码成你的值。

      【讨论】:

        【解决方案3】:

        是的,你可以,但它不是保证值,因为它可以被清除。不过,我只建议在开发环境中检查这一点。

        function getMemcacheKeys() {
        
            $memcache = new Memcache;
            $memcache->connect('localhost', 11211) or die ("Could not connect to memcache server");
        
            $list = array();
            $allSlabs = $memcache->getExtendedStats('slabs');
            foreach($allSlabs as $server => $slabs) {
                foreach($slabs AS $slabId => $slabMeta) {
                   if (!is_numeric($slabId)) {
                        continue;
                   } 
                   $cdump = $memcache->getExtendedStats('cachedump',(int)$slabId);
                    foreach($cdump AS $keys => $arrVal) {
                        if (!is_array($arrVal)) continue;
                        foreach($arrVal AS $k => $v) {                   
                            echo $k .' - '.date('H:i d.m.Y',$v[1]).'<br />';
                        }
                   }
                }
            }   
        }
        

        复制自:https://stackoverflow.com/a/7480534/338840

        【讨论】:

          猜你喜欢
          • 2012-09-04
          • 2010-11-27
          • 1970-01-01
          • 2011-01-27
          • 2013-03-09
          • 2014-06-22
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多