def CachedClearValue(key): try: mc = memcached_wrapper.getMemcached() mc.delete(str(key).replace(' ', '')) mc.disconnect_all() except Exception, e: print "Memcached clear error ,key" print Exception, ":", e print key
def checkSession(token): key = str(token) mc = memcached_wrapper.getMemcached() value = mc.get(key) mc.disconnect_all() if value == None: return False else: return True
def getToken(username, password): key = '_'.join(['hqms_adv', 'user', username, createRandomStr32(8)]) value_json = {} value_json['username'] = username value = json.dumps(value_json) mc = memcached_wrapper.getMemcached() mc.set(str(key), value, cfg.memcached_timeout) mc.disconnect_all() return key
def CahedSetValue(key, value, timeout): try: mc = memcached_wrapper.getMemcached() ret = mc.set(str(key).replace(' ', ''), value, timeout) mc.disconnect_all() return ret except Exception, e: print "Memcached set error " print Exception, ":", e print key print value
def CachedGetValue(key): try: mc = memcached_wrapper.getMemcached() value = mc.get(str(key).replace(' ', '')) mc.disconnect_all() if value == None: return False else: return value except Exception, e: print "Memcached get val error " print Exception, ":", e print key print value