from uuid import uuid4

from playlog.config import SESSION_LIFETIME


KEY = 'playlog:session'


async def create(redis):
    sid = uuid4().hex
    await redis.execute('setex', KEY, SESSION_LIFETIME, sid)
    return sid


async def get(redis):
    sid = await redis.execute('get', KEY)
    if sid:
        sid = sid.decode('utf-8')
    return sid


async def verify(redis, sid):
    current_sid = await get(redis)
    return current_sid and (current_sid == sid)

174ce503d440f02866db0470e05c15f21162959c
<mask token>

<mask token>


async def create(redis):
    sid = uuid4().hex
    await redis.execute('setex', KEY, SESSION_LIFETIME, sid)
    return sid


async def get(redis):
    sid = await redis.execute('get', KEY)
    if sid:
        sid = sid.decode('utf-8')
    return sid


async def verify(redis, sid):
    current_sid = await get(redis)
    return current_sid and current_sid == sid

<mask token>
KEY = 'playlog:session'


async def create(redis):
    sid = uuid4().hex
    await redis.execute('setex', KEY, SESSION_LIFETIME, sid)
    return sid


async def get(redis):
    sid = await redis.execute('get', KEY)
    if sid:
        sid = sid.decode('utf-8')
    return sid


async def verify(redis, sid):
    current_sid = await get(redis)
    return current_sid and current_sid == sid

from uuid import uuid4
from playlog.config import SESSION_LIFETIME
KEY = 'playlog:session'


async def create(redis):
    sid = uuid4().hex
    await redis.execute('setex', KEY, SESSION_LIFETIME, sid)
    return sid


async def get(redis):
    sid = await redis.execute('get', KEY)
    if sid:
        sid = sid.decode('utf-8')
    return sid


async def verify(redis, sid):
    current_sid = await get(redis)
    return current_sid and current_sid == sid

from uuid import uuid4

from playlog.config import SESSION_LIFETIME


KEY = 'playlog:session'


async def create(redis):
    sid = uuid4().hex
    await redis.execute('setex', KEY, SESSION_LIFETIME, sid)
    return sid


async def get(redis):
    sid = await redis.execute('get', KEY)
    if sid:
        sid = sid.decode('utf-8')
    return sid


async def verify(redis, sid):
    current_sid = await get(redis)
    return current_sid and (current_sid == sid)
