Skip to content

Use flushdb instead of flushall in RedisCacheAdapter #3523

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

Merged
merged 1 commit into from
Feb 19, 2017

Conversation

JeremyPlease
Copy link
Contributor

When a different db on the same redis server is used by another service Parse Server will currently flush that db on clear().

The Parse Server RedisCacheAdapter only reads/writes to one db on the redis server and should only flush that database (instead of all databases).

This fix replaces flushall with flushdb.

Copy link
Contributor

@flovilmart flovilmart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very good catch!

@flovilmart flovilmart merged commit 6ae0675 into parse-community:master Feb 19, 2017
@stefanraffeiner
Copy link

@JeremyPlease @flovilmart I'm trying to better understand how the ParseServer redis Cache behaves. When two services (in our case ParseServer and Kue) use the same redis database, also flushdb would clear data for both services, right?
Wouldn't it be better to only remove keys that are prefixed with the parse appId? Please let me know if I'm missing something.

@JeremyPlease
Copy link
Contributor Author

@stefanraffeiner Unfortunately, redis doesn't have a simple command for "delete all keys that match prefix." To do that, we would need to read all keys that match prefix and delete each.

I think the best thing to do is use different redis "databases" for each of your services. By default, redis has 6 databases (indexed from 0 to 15). You can set the db option in the redis configuration (docs here). For instance, Parse redis cache could use db 0 and Kue could use db 1. Then when Parse redis cache flushes db 0 the Kue database is left untouched.

Hope that helps!

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

Successfully merging this pull request may close these issues.

4 participants