Beispiel #1
0
    async def EXPIRE(self, count):
        if count != 2:
            return Resp.error('wrong number of arguments for EXPIRE command')
        key = await self.get_key()

        seconds = await self.get_key()

        try:
            seconds = int(seconds)
        except ValueError:
            return Resp.error('value is not an integer')

        if self.db.expire(key, seconds):
            TIME.expire(key)
            return Resp.integer(1)
        return Resp.integer(0)
Beispiel #2
0
    async def DEL(self, count):
        if count < 1:
            return Resp.error('wrong number of arguments for TYPE command')

        keys = {await self.get_key() for _ in range(count)}

        return Resp.integer(self.db.del_(keys))
Beispiel #3
0
    async def TTL(self, count):
        if count != 1:
            return Resp.error('wrong number of arguments for TTL command')
        key = await self.get_key()

        return Resp.integer(self.db.ttl(key))
Beispiel #4
0
 async def PERSIST(self, count):
     if count != 1:
         return Resp.error('wrong number of arguments for PERSIST command')
     key = await self.get_key()
     return Resp.integer(TIME.persist(key))