Skip to content
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

Cache users by objectID, and clear cache when updated via master key (fixes #1836) #1844

Merged

Conversation

drew-gross
Copy link
Contributor

Previously users were cached by session token, which doesn't work when using master key to update a user, as we don't know the session token, and would have to do an extra query to get it. This caches by objectId so that they user cache can be cleared when the user is updated via master key.

@codecov-io
Copy link

codecov-io commented May 19, 2016

Current coverage is 91.97%

Merging #1844 into master will decrease coverage by <.01%

  1. File src/Auth.js was modified. more
    • Misses +2
    • Partials 0
    • Hits -2
@@             master      #1844   diff @@
==========================================
  Files            91         91          
  Lines          6363       6362     -1   
  Methods        1096       1096          
  Messages          0          0          
  Branches       1332       1332          
==========================================
- Hits           5854       5851     -3   
- Misses          509        511     +2   
  Partials          0          0          

Powered by Codecov. Last updated by b218368...6c7a90e

@blacha
Copy link
Contributor

blacha commented May 19, 2016

Where do we actually query this? if you change the put key, you will need to change the get key?

@drew-gross
Copy link
Contributor Author

Oh yeah good point. We should probably have a test to ensure that the cache actually gets used..

…sion when user is modified with Master Key (ew, hopefully that can be improved later)
@ghost
Copy link

ghost commented May 20, 2016

@drew-gross updated the pull request.

// Update was made with master key, so we don't have the session. Query to find it. Hopefully we can make this faster later, somehow.
let userObject = Parse.Object.createWithoutData('_User', this.data.objectId);
let sessionsQuery = new Parse.Query('_Session');
//sessionsQuery.equalTo('user', userObject);
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this line be commented out? Seems like there are no constraints on the query?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nope I'm still working on this PR. The original issue was when a user was updated via master key, but the same issue will show up if the user is updated via one session token and the read via a different one. I'll mark is as WIP.

@drew-gross drew-gross changed the title Cache users by objectID, and clear cache when updated via master key (fixes #1836) [WIP] Cache users by objectID, and clear cache when updated via master key (fixes #1836) May 20, 2016
@ghost
Copy link

ghost commented May 21, 2016

@drew-gross updated the pull request.

@ghost
Copy link

ghost commented May 21, 2016

@drew-gross updated the pull request.

@ghost
Copy link

ghost commented May 21, 2016

@drew-gross updated the pull request.

@drew-gross drew-gross changed the title [WIP] Cache users by objectID, and clear cache when updated via master key (fixes #1836) Cache users by objectID, and clear cache when updated via master key (fixes #1836) May 21, 2016
@drew-gross
Copy link
Contributor Author

@blacha this PR is finished now.

@blacha
Copy link
Contributor

blacha commented May 22, 2016

looks good to me.

@drew-gross drew-gross merged commit 392102e into parse-community:master May 22, 2016
@drew-gross drew-gross deleted the fresh-user-in-cloud-code branch May 22, 2016 16:59
JeremyPlease pushed a commit to JeremyPlease/parse-server that referenced this pull request May 24, 2016
…ixes parse-community#1836) (parse-community#1844)

* Cache users by objectID, and clear cache when updated via master key

* Go back to caching by session token. Clear out cache by querying _Session when user is modified with Master Key (ew, hopefully that can be improved later)

* Fix issue with user updates from different sessions causing stale reads

* Tests aren't transpiled...

* Still not transpiled
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