Add optional persistent sessions across PHP requests#151
Conversation
…oken across multiple PHP requests.
|
I am changing this to a draft since I will want to look at this some further. Some parts may change until I'm ready with it, but this should be a good starting point of what I was trying to accomplish. |
|
I see that this is essentially two different features, persistent sessions and a retry mechanism. I'll move these to different PRs as they are not dependent on each other. |
|
@filiptorphage-mjuk, Thanks for committing fine code! I think there is no issues on your pull request. I will merge. |
|
I did point out a flaw of this PR that needed to be fixed (it's currently broken), which is why I changed it to a draft. And there were some things that I would have preferred to have a second look at first.
There might be more things, but now that you have actually merged this PR, what would you recommend to be the best course of action? @msyk |
|
@msyk, I would like to make some adjustments before I think this is ready to be merged, I was too hasty with creating this PR as I didn't expect it to be merged so soon. Would you prefer to revert this PR, or for me to simply create a new PR with just the adjustments I would like to make? |
|
OK. I will back to it. |
Could you open the new issue to discuss your proposals? |
This PR adds optional support for reusing a FileMaker Data API access token across multiple PHP requests, as discussed in issue #150.
It introduces:
PersistentSessionSessionCacheInterfaceApcuSessionCacheFMDataAPIThe intended flow is:
The feature is optional. FMDataAPI continues to work without APCu, but persistent-session support requires either APCu or a user-provided
SessionCacheInterfaceimplementation.One current limitation is that the retry logic does not yet fully work when
setThrowException(true)is enabled, because the error state is not always populated before an exception is thrown in the lower-level request flow. This does not currently work sinceerrorCode()hasn't been populated here. I believe the best solution would be to make surestoreToProperties()is always called aftercallRestAPI(), even when an exception is thrown.The intended split is:
startCommunication()for keeping a session open within one PHP requestbeginPersistentSession()for reusing a session across multiple PHP requestsFeedback
This PR is my proposed implementation of the feature request.
If you have any feedback or just opinions, feel free to bring them up.