def test_cache(): from bae_memcache.cache import BaeMemcache ### 创建一个cache cache = BaeMemcache("fUqxFBdrJSizQFSqxGUI", "cache.duapp.com:20243", "apikey", "secretkey") body = [] ### 存放一个key,value对 if cache.set('key', 'value'): body.append("set key => value success!") ### 获取key对应的value body.append("get %s success!"%cache.get('key')) return body
def test_cache(): from bae_memcache.cache import BaeMemcache ### 创建一个cache cache = BaeMemcache("fUqxFBdrJSizQFSqxGUI", "cache.duapp.com:20243", "apikey", "secretkey") body = [] ### 存放一个key,value对 if cache.set('key', 'value'): body.append("set key => value success!") ### 获取key对应的value body.append("get %s success!" % cache.get('key')) return body
return url, url def delete_file(file_path): from urlparse import urlsplit from settings import bos_client, const path = urlsplit(file_path).path _, bucket_name, object_name = path.split("/", 2) object_name = "/" + object_name bos_client.delete_object(bucket_name, object_name) ############################################ ## memcache ############################################ from settings import const, ENABLE_MEMCACHE if ENABLE_MEMCACHE: from bae_memcache.cache import BaeMemcache from tools import fail_safe_func # bind memcache to BAE memcache = BaeMemcache(const.CACHE_ID, const.CACHE_ADDR, const.CACHE_USER, const.CACHE_PASS) memcache.flush_all = lambda: None memcache.set = fail_safe_func(memcache.set)
return url, url def delete_file(file_path): from urlparse import urlsplit from settings import BAE_BCS path = urlsplit(file_path).path _, bucket_name, object_name = path.split("/", 2) object_name = "/" + object_name bucket = BAE_BCS.bucket(bucket_name) bcs_obj = bucket.object(object_name) bcs_obj.delete() ############################################ ## memcache ############################################ from settings import const, ENABLE_MEMCACHE if ENABLE_MEMCACHE: from bae_memcache.cache import BaeMemcache from tools import fail_safe_func # bind memcache to BAE memcache = BaeMemcache(const.CACHE_ID, const.CACHE_ADDR, const.CACHE_USER, const.CACHE_PASS) memcache.flush_all = lambda: None memcache.set = fail_safe_func(memcache.set)