Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When using memcached, specifying TTL in set_config results in an error. #663

Open
reeya2022 opened this issue Feb 12, 2023 · 1 comment
Open

Comments

@reeya2022
Copy link

Hello.
When using memcached, specifying TTL in set_config results in an error.
Thanks.

aiocache 0.12.0
Python 3.9.7

import asyncio
from aiocache import caches

caches.set_config({
    'default': {
        'cache': "aiocache.SimpleMemoryCache",
        'serializer': {
            'class': "aiocache.serializers.PickleSerializer"
        },
    },
    'memcached': {
        'cache': "aiocache.MemcachedCache",
        'serializer': {
            'class': "aiocache.serializers.PickleSerializer"
        },
        'ttl': int(3),
    }
})

async def main():
    cache = caches.create('memcached')
    await cache.set('key', 'value')
    ret = await cache.get('key')
    print(ret)

asyncio.run(main())
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/aiocache/backends/memcached.py", line 44, in _set
    return await self.client.set(key, value, exptime=ttl or 0)
  File "/usr/local/lib/python3.9/site-packages/aiomcache/client.py", line 42, in wrapper
    return await func(self, conn, *args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/aiomcache/client.py", line 338, in set
    return await self._storage_command(conn, b"set", key, value, exptime)
  File "/usr/local/lib/python3.9/site-packages/aiomcache/client.py", line 302, in _storage_command
    raise ValidationException('exptime not int', exptime)
aiomcache.exceptions.ValidationException: exptime not int: 3.0
@Dreamsorcerer
Copy link
Member

Feel free to provide a PR to fix this in the 0.x releases.
But, I expect the entire config functionality will be removed in 1.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants