Forums

Redislite with django

Hi all.

I am using django for my project andi am using redis on my local server and it works good but in pythonanywhere, i want to use redislite but it does not work. Its probably bcause of settings. It gives connection error. Whats redislite settings for django?

Not: Both django and redislite works on virtualenv and redis-server also working when i try to cache it. and sorry for bad english.

When you create your Redis or StrictRedis object for redislite, you should specify a file path, not an address and port, like you do with redis.

I see but i can use it just on my pc with "redis-server" command in virtualenv. do nothing more.

The regular redis server won't work on PythonAnywhere, just redislite.

Its redislite but i dont know whats the settings.

You need to specify a file to say where the redis database lives, like this:

redis_connection = Redis('/tmp/redis.db')

The redislite documentation is pretty good.

Its confusing. I want to use for cache, which it works perfect on my pc, just specify django settings.py like redis. I dont do anywthing more. And, i specify which file? django settings.py?

Specify the file where you want the redis database to live. As described in the post that giles posted and in the redislite documentation.

The latest version of Django, version 4, now supports Redis as a cache back-end.

It would be a kindness if this thread were updated with info about what specifically one puts in settings.CACHES to use redislite.

Neither the redislite docs nor the Django docs currently offer this info, as far as I can see.

Actually, we don't know if redislite would work as a cache back-end with Django. Did you try to implement it?

I've tried and in fact it doesn't look like it's possible with stock Django and stock redislite. Too bad! I'd love a cache store whose keys I could list, a la Redis.

As you have a paid account, perhaps you could get a redis server separately from Redis Labs? They have free and cheap options, and if you put it into the AWS us-east-1 datacenter it will be close to our own machines, so you should get low latency.

I would like to know if this worked for Paul

@imranrajjad Redislite can't be used as a Django cache backend, so I didn't go any farther with it.

If you're asking about giles' suggestion that I get a server from Redis Labs, I haven't pursued that, as I don't have a pressing need for it right now.