-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Adding Caching Adapter, allows caching of _Role, _User and _SCHMEA (fixes #168) #1664
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
Conversation
@blacha updated the pull request. |
1 similar comment
@blacha updated the pull request. |
@@ -0,0 +1,70 @@ | |||
const DEFAULT_CACHE_TTL = 60 * 1000; |
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.
Anyway to override this value with an ENV variable ou CLI option or Config value ?
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.
You can create a InMemoryCacheAdapter
with any TTL you want when you initialize the server.
new ParseServer({
cacheAdapter: new InMemoryCacheAdapter({ttl: 24 * 60 * 60 * 1000})
})
or you can completely disable it by having a cacheAdapter that just Promise.resolve(null)
for gets/sets/del/clear
The TTL is only for Sessions, Roles and SCHEMA queries
Also any time a user modifies a Role or a Session the cache for those get destroyed.
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.
I'd still provide an option/env in the CLI.
Current coverage is 92.40%
@@ master #1664 diff @@
==========================================
Files 87 91 +4
Lines 6201 6240 +39
Methods 1070 1083 +13
Messages 0 0
Branches 1289 1269 -20
==========================================
+ Hits 5721 5766 +45
+ Misses 480 474 -6
Partials 0 0
|
@blacha not trying to be pedantic 🙈 but any reason you're calling the set cache method Would it make more sense to call it |
@flovilmart or @nlutsenko any thoughts here? |
@Salakar I based the implementation off library that I've used in the past and that used Ill update this pull request when I get home from work. |
@blacha updated the pull request. |
A couple comments:
|
|
|
ttl = NaN; | ||
} | ||
|
||
var record = { |
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.
Should we handle value == null as a delete?
@blacha updated the pull request. |
@blacha updated the pull request. |
Here is another implementation for reference: https://github.com/maysale01/parse-server/blob/new-memory-cache/src/classes/MemoryCache.js |
No description provided.