cunla / fakeredis-py

Implementation of Redis in python without having a Redis server running. Fully compatible with using redis-py.

Home Page:https://fakeredis.moransoftware.ca/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

EXAT option does not work

Beduir opened this issue · comments

Describe the bug
EXAT option in set-method does not work, raises an exception.

To Reproduce

import asyncio

import redis.asyncio as aioredis
from fakeredis import FakeAsyncRedis


async def test(redis):
    await redis.set('test', '1', exat=1706632494)


async def test_pipeline(redis):
    async with redis.pipeline() as pipe:
        await pipe.set('test', '1', exat=1706632494)
        await pipe.execute()


async def run_test():
    fake_redis = FakeAsyncRedis()
    redis = aioredis.Redis()
    await test(redis)   # <--- This will OK
    await test_pipeline(redis)   # <--- This will OK
    await test(fake_redis)   # <--- This will fail
    await test_pipeline(fake_redis)   # <--- This will fail


if __name__ == '__main__':
    asyncio.run(run_test())
Exception has occurred: ResponseError
syntax error
  File "/home/beduir/dev/python/test/test.py", line 8, in test
    await redis.set('test', '1', exat=1706632494)
  File "/home/beduir/dev/python/test/test.py", line 22, in run_test
    await test(fake_redis)
  File "/home/beduir/dev/python/test/test.py", line 27, in <module>
    asyncio.run(run_test())
redis.exceptions.ResponseError: syntax error
Exception has occurred: ResponseError
Command # 1 (SET test 1 EXAT 1706632494) of pipeline caused error: ('syntax error',)
  File "/home/beduir/dev/python/test/test.py", line 14, in test_pipeline
    await pipe.execute()
  File "/home/beduir/dev/python/test/test.py", line 23, in run_test
    await test_pipeline(fake_redis)
  File "/home/beduir/dev/python/test/test.py", line 27, in <module>
    asyncio.run(run_test())
redis.exceptions.ResponseError: Command # 1 (SET test 1 EXAT 1706632494) of pipeline caused error: ('syntax error',)

Expected behavior
Doesn't raise an exception.

Desktop (please complete the following information):

  • OS: WSL 2
  • python version 3.11.7
  • redis-py version 5.0.1
  • full requirements.txt?
fakeredis==2.20.1
redis==5.0.1
sortedcontainers==2.4.0

Thanks for bringing this up. EXAT/PXAT were added in 6.2/7.2.
It is easy to add support for them, I should do it today/tomorrow.
I am planning to release a new ver this weekend.