示例#1
0
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
示例#2
0
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
示例#3
0
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
示例#4
0
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
示例#5
0
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