Skip to content

adding TTL option for redis cache adapter #3397

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 8 commits into from
Feb 27, 2017

Conversation

f0ster
Copy link
Contributor

@f0ster f0ster commented Jan 19, 2017

No description provided.

@acinader
Copy link
Contributor

@f0ster this looks good to me. would you be willing to write a unit test that proves that the default constructor value works as expected?

@facebook-github-bot
Copy link

@f0ster updated the pull request - view changes

@f0ster
Copy link
Contributor Author

f0ster commented Jan 23, 2017

@acinader I will take a look, I didn't see any unit tests for the other cache adapters testing parameters so I didn't include..

@facebook-github-bot
Copy link

@f0ster updated the pull request - view changes

@facebook-github-bot
Copy link

@f0ster updated the pull request - view changes

@f0ster
Copy link
Contributor Author

f0ster commented Jan 25, 2017

@facebook-github-bot
Copy link

@f0ster updated the pull request - view changes

@@ -1,17 +1,18 @@
import redis from 'redis';
import logger from '../../logger';

const DEFAULT_REDIS_TTL = 30 * 1000; // 30 seconds in milliseconds
const DEFAULT_REDIS_TTL = 30; // 30 seconds in milliseconds

Choose a reason for hiding this comment

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

comment not true anymore

Copy link
Contributor

Choose a reason for hiding this comment

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

@f0ster why the change here?

https://github.com/f0ster/parse-server/blob/947471bc00c3b049278b61e0707b2f64cac13605/src/Adapters/Cache/RedisCacheAdapter.js#L50

we use psetex https://redis.io/commands/psetex

so if i've got it right, this change is not good? cause we'll just cache for 30 millis by default.

PS sorry for the delay.

cache.put(KEY, VALUE)
.then(() => cache.get(KEY))
.then((value) => expect(value).toEqual(VALUE))
.then(wait.bind(null, 50))
Copy link
Contributor

Choose a reason for hiding this comment

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

nice idiom.


cache.put(KEY, VALUE)
.then(() => cache.get(KEY))
.then((value) => expect(value).toEqual(VALUE))
Copy link
Contributor

Choose a reason for hiding this comment

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

what!@?! mind blown. I don't even understand how returning expect.... is "thenable", but super cool idiom. going to start using....

@acinader
Copy link
Contributor

acinader commented Feb 8, 2017

@f0ster super nice tests. thanks. just one outstanding issue on seconds v millis.

@facebook-github-bot
Copy link

@f0ster updated the pull request - view changes

@f0ster
Copy link
Contributor Author

f0ster commented Feb 22, 2017

@acinader I've gone ahead and updated the default ttl to use ms

Arthur Cinader and others added 2 commits February 22, 2017 22:14
make timeout values really really small so our test run fast :).
Fix the redis cache spec to construct the cache with the anticipated ttl
@facebook-github-bot
Copy link

@f0ster updated the pull request - view changes

@acinader
Copy link
Contributor

Grrrr, not sure why that test is failing. Obviously it works locally and may just be that the times are too short! And it passed once and failed once :(

In any event I'd like to play with it a bit to see if I can reproduce, understand and fix, but it'll take a few days before I can look at it.

@acinader
Copy link
Contributor

So I couldn't reproduce the problem and when i re-ran the test it worked. So I am going to merge this now and i'll watch the tests over the next few days. if this sucker keeps failing i'll increase the tolerances.

@acinader acinader merged commit e6006e8 into parse-community:master Feb 27, 2017
@f0ster
Copy link
Contributor Author

f0ster commented Mar 1, 2017

@acinader Awesome, thank you. I was also unable to reproduce, perhaps it was some sort of race condition ?

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