Suor / django-cacheops

A slick ORM cache with automatic granular event-driven invalidation.
BSD 3-Clause "New" or "Revised" License
2.09k stars 227 forks source link

Lua redis() command arguments must be strings or integers #355

Closed omegion closed 4 years ago

omegion commented 4 years ago

Hi, When I try to use caching on my application, I get the following error from running Redis server.

File "/Users/cheppers/opt/miniconda3/envs/crawly-app/lib/python3.8/site-packages/django/utils/functional.py", line 224, in inner
    self._setup()
  File "/Users/cheppers/opt/miniconda3/envs/crawly-app/lib/python3.8/site-packages/django/utils/functional.py", line 360, in _setup
    self._wrapped = self._setupfunc()
  File "/Users/cheppers/opt/miniconda3/envs/crawly-app/lib/python3.8/site-packages/django/contrib/auth/middleware.py", line 24, in <lambda>
    request.user = SimpleLazyObject(lambda: get_user(request))
  File "/Users/cheppers/opt/miniconda3/envs/crawly-app/lib/python3.8/site-packages/django/contrib/auth/middleware.py", line 12, in get_user
    request._cached_user = auth.get_user(request)
  File "/Users/cheppers/opt/miniconda3/envs/crawly-app/lib/python3.8/site-packages/django/contrib/auth/__init__.py", line 180, in get_user
    user = backend.get_user(user_id)
  File "/Users/cheppers/opt/miniconda3/envs/crawly-app/lib/python3.8/site-packages/django/contrib/auth/backends.py", line 161, in get_user
    user = UserModel._default_manager.get(pk=user_id)
  File "/Users/cheppers/opt/miniconda3/envs/crawly-app/lib/python3.8/site-packages/django/db/models/manager.py", line 82, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/Users/cheppers/opt/miniconda3/envs/crawly-app/lib/python3.8/site-packages/cacheops/query.py", line 390, in get
    return qs._no_monkey.get(qs, *args, **kwargs)
  File "/Users/cheppers/opt/miniconda3/envs/crawly-app/lib/python3.8/site-packages/django/db/models/query.py", line 411, in get
    num = len(clone)
  File "/Users/cheppers/opt/miniconda3/envs/crawly-app/lib/python3.8/site-packages/django/db/models/query.py", line 258, in __len__
    self._fetch_all()
  File "/Users/cheppers/opt/miniconda3/envs/crawly-app/lib/python3.8/site-packages/cacheops/query.py", line 321, in _fetch_all
    self._cache_results(cache_key, self._result_cache)
  File "/Users/cheppers/opt/miniconda3/envs/crawly-app/lib/python3.8/site-packages/cacheops/query.py", line 206, in _cache_results
    cache_thing(self._prefix, cache_key, results,
  File "/Users/cheppers/opt/miniconda3/envs/crawly-app/lib/python3.8/site-packages/cacheops/query.py", line 46, in cache_thing
    load_script('cache_thing', settings.CACHEOPS_LRU)(
  File "/Users/cheppers/opt/miniconda3/envs/crawly-app/lib/python3.8/site-packages/redis/client.py", line 4067, in __call__
    return client.evalsha(self.sha, len(keys), *args)
  File "/Users/cheppers/opt/miniconda3/envs/crawly-app/lib/python3.8/site-packages/redis/client.py", line 3143, in evalsha
    return self.execute_command('EVALSHA', sha, numkeys, *keys_and_args)
  File "/Users/cheppers/opt/miniconda3/envs/crawly-app/lib/python3.8/site-packages/redis/client.py", line 901, in execute_command
    return self.parse_response(conn, command_name, **options)
  File "/Users/cheppers/opt/miniconda3/envs/crawly-app/lib/python3.8/site-packages/redis/client.py", line 915, in parse_response
    response = connection.read_response()
  File "/Users/cheppers/opt/miniconda3/envs/crawly-app/lib/python3.8/site-packages/redis/connection.py", line 747, in read_response
    raise response
redis.exceptions.ResponseError: Error running script (call to f_f6b93ec749d56aefa37c49bbc5e7a6eedd0d4ec3): @user_script:15: @user_script: 15: Lua redis() command arguments must be strings or integers 

System:

aiohttp==3.6.2
aioredis==1.3.1
amqp==2.5.2
aniso8601==7.0.0
asgiref==3.2.7
astroid==2.3.3
async-timeout==3.0.1
attrs==19.3.0
autobahn==20.4.3
Automat==20.2.0
billiard==3.6.3.0
braintree==4.1.0
celery==4.4.2
certifi==2020.4.5.1
cffi==1.14.0
channels==2.4.0
channels-redis==2.4.2
chardet==3.0.4
click==7.1.2
constantly==15.1.0
cryptography==2.9.2
cssselect==1.1.0
daphne==2.5.0
defusedxml==0.7.0rc1
Django==3.0.6
django-admin-autocomplete-filter==0.5
django-admin-sortable2==0.7.6
django-cacheops==5.0
django-celery-results==1.2.1
django-ckeditor==5.9.0
django-cleanup==4.0.0
django-cors-headers==3.2.1
django-currentuser==0.5.0
django-filter==2.2.0
django-graphql-jwt==0.3.1
django-js-asset==1.2.2
django-redis==4.11.0
dodgy==0.2.1
Faker==4.1.0
funcy==1.14
graphene==2.1.8
graphene-django==2.10.0
graphql-core==2.3.2
graphql-relay==2.0.1
gunicorn==20.0.4
h11==0.9.0
hiredis==1.0.1
httptools==0.1.1
hyperlink==19.0.0
idna==2.9
incremental==17.5.0
isort==4.3.21
kombu==4.6.8
lazy-object-proxy==1.4.3
lxml==4.5.0
mccabe==0.6.1
more-itertools==8.3.0
msgpack==0.6.2
multidict==4.7.6
oauthlib==3.1.0
packaging==20.3
parsel==1.6.0
pep8-naming==0.4.1
pluggy==0.13.1
promise==2.3
prospector==1.2.0
Protego==0.1.16
psycopg2-binary==2.8.5
py==1.8.1
pyasn1==0.4.8
pyasn1-modules==0.2.8
pycodestyle==2.4.0
pycparser==2.20
PyDispatcher==2.0.5
pydocstyle==5.0.2
pyflakes==2.1.1
PyHamcrest==2.0.2
PyJWT==1.7.1
pylint==2.4.4
pylint-celery==0.3
pylint-django==2.0.12
pylint-flask==0.6
pylint-plugin-utils==0.6
pyOpenSSL==19.1.0
pyparsing==2.4.7
pytest==5.4.2
pytest-django==3.9.0
python-dateutil==2.8.1
python-decouple==3.3
python3-openid==3.1.0
pytz==2020.1
PyYAML==5.3.1
queuelib==1.5.0
redis==3.5.2
requests==2.23.0
requests-oauthlib==1.3.0
requirements-detector==0.6
Rx==1.6.1
Scrapy==2.1.0
scrapy-splash==0.7.2
sentry-sdk==0.14.4
service-identity==18.1.0
setoptconf==0.2.0
singledispatch==3.4.0.3
six==1.14.0
snowballstemmer==2.0.0
social-auth-app-django==3.1.0
social-auth-core==3.3.3
sqlparse==0.3.1
text-unidecode==1.3
Twisted==20.3.0
txaio==20.4.1
urllib3==1.25.9
uvicorn==0.11.5
uvloop==0.14.0
vine==1.3.0
w3lib==1.22.0
wcwidth==0.1.9
websockets==8.1
whitenoise==5.0.1
wrapt==1.11.2
yarl==1.4.2
zope.interface==5.1.0

Redis Version:

6.0.3
Suor commented 4 years ago

Can you create a test for it? This will help a lot. You can read on how to do it in README.

Suor commented 4 years ago

It's impossible to troubleshoot this without any input. You might simply have some weird settings.