/** * 使缓存失效 */ public static function invalid($paramArr) { $options = array('module' => false, 'tbl' => 'tbl', 'key' => false, 'retry' => true); if (is_array($paramArr)) { $options = array_merge($options, $paramArr); } extract($options); if (!$module || !isset(self::$_cacheCfg[$module])) { return false; } $cfg = self::$_cacheCfg[$module]["write"]; #服务器数据 $server = $cfg["server"]; $db = $module; $md5key = md5($key); $tbl = $tbl ? $tbl : "tbl"; $collection = $tbl . '_' . substr($md5key, 0, 2); try { $colObj = API_MongoDB::selectCollection($server, $db, $collection); $colObj->update(array("_id" => $md5key), array('$set' => array("life" => SYSTEM_TIME))); } catch (Exception $e) { if (!empty($options['retry'])) { $options['retry'] = false; self::invalid($options); } } }