function s_user_by_domain($domain) { if (s_bad_string($domain, $domain)) { return false; } $key = "user_by_domain_" . $domain; $params = array("domain" => $domain); if (false === ($data = s_memcache_get($key)) || false === ($user = s_weibo_http("/users/domain_show.json", $params))) { //缓存中不存在 return false; } //获取uid,从缓存中获取用户信息 return s_user_by_uid($uid); }
function s_memcache($key, &$value = false, $time = 300) { if (s_bad_string($key)) { return false; } if ($value === false) { //获取memcache值 return s_memcache_get($key); } else { //设置memcache值 return s_memcache_set($key, $value, $time); } return false; }
function s_memcache($key, $value = false, $method = "set") { return false; if (s_bad_string($key)) { return false; } if ($value === false) { //获取memcache值 return s_memcache_get($key); } else { if ($method === "set") { //设置memcache值 return s_memcache_set($key, $value); } } return false; }
function s_memcache($key, &$value = false, $time = 300, $replace = false) { if (s_bad_string($key)) { return false; } if ($replace === true && s_memcahce_get($key) !== false) { //替换操作 return s_memcache_reset($key, $value, $time); } else { if ($value === false) { //获取memcache值 return s_memcache_get($key); } else { //设置memcache值 return s_memcache_set($key, $value, $time); } } return false; }