Skip to content

Expire values in RedisCacheAdapter #2988

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
Nov 2, 2016

Conversation

TylerBrock
Copy link
Contributor

So I'm trying the RedisCacheAdapter and it looks like it just sets keys forever. I think they should expire, most likely after 30 seconds.

@facebook-github-bot
Copy link

@TylerBrock updated the pull request - view changes

@flovilmart flovilmart merged commit 33ebedf into parse-community:master Nov 2, 2016
@@ -1,6 +1,8 @@
import redis from 'redis';
import logger from '../../logger';

const DEFAULT_REDIS_TTL = 30 * 1000; // 30 seconds
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't think we use this here so could be removed.

Currently the schema cache TTL is passed in to ParseServer as schemaCacheTTL and then passed to the adapter with each put(). However InMemoryCache does have a default TTL if no value is passed in from the adapter, so you might want to implement?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Arg, I had something there initially where if TTL wasn't provided we'd use one but the lockout tests wouldn't pass. I meant to remove that for the time being.

this.client.set(key, value, function(err, res) {
resolve();
});
if (ttl) {
Copy link
Contributor

Choose a reason for hiding this comment

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

The logic in InMemoryCache is a little different:
TTL = 0 means store but have immediately expire, e.g. in tests.
TTL = NaN means never expire.

Your change has TTL = 0 never expiring and I'm not sure what happens when NaN is passed to psetex().
I would change to match InMemoryCache

Copy link
Contributor Author

@TylerBrock TylerBrock Nov 2, 2016

Choose a reason for hiding this comment

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

👍 Thank you that was the piece of information I was looking for, I'll update.

I saw this login in the InMemory cache but assumed zero meant never expire not immediately expire. That's why the tests wouldn't pass.

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