-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
import redis from 'redis'; | ||
import logger from '../../logger'; | ||
|
||
const DEFAULT_REDIS_TTL = 30 * 1000; // 30 seconds | ||
|
||
function debug() { | ||
logger.debug.apply(logger, ['RedisCacheAdapter', ...arguments]); | ||
} | ||
|
@@ -33,9 +35,15 @@ export class RedisCacheAdapter { | |
debug('put', key, value, ttl); | ||
this.p = this.p.then(() => { | ||
return new Promise((resolve, _) => { | ||
this.client.set(key, value, function(err, res) { | ||
resolve(); | ||
}); | ||
if (ttl) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The logic in InMemoryCache is a little different: Your change has TTL = 0 never expiring and I'm not sure what happens when NaN is passed to psetex(). There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
this.client.psetex(key, ttl, value, function(err, res) { | ||
resolve(); | ||
}); | ||
} else { | ||
this.client.set(key, value, function(err, res) { | ||
resolve(); | ||
}); | ||
} | ||
}); | ||
}); | ||
return this.p; | ||
|
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.