-
Notifications
You must be signed in to change notification settings - Fork 12
Add developer cache #110
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
base: master
Are you sure you want to change the base?
Add developer cache #110
Conversation
Apigee/ManagementAPI/Developer.php
Outdated
| $developer->attributes[$attribute['name']] = @$attribute['value']; | ||
| foreach ($response['attributes'] as $key => $attribute) { | ||
| if (is_array($attribute)) { | ||
| $developer->attributes[$attribute['name']] = @$attribute['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.
What kind of errors needs to be suppressed here? The only that I can imagine is the 'value' index does not exist which should not happen.
| $developer->createdBy = $response['createdBy']; | ||
| $developer->modifiedAt = $response['lastModifiedAt']; | ||
| $developer->modifiedBy = $response['lastModifiedBy']; | ||
| $developer->modifiedAt = array_key_exists('lastModifiedAt', $response) ? $response['lastModifiedAt'] : $response['modifiedAt']; |
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.
In which circumstances we get back "modifiedAt" instead of "lastModifiedAt"?
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.
It's different on the object and on the response... I had to make sure it is compatible.
Apigee/ManagementAPI/Developer.php
Outdated
| $data[$organization] = array( | ||
| 'developers' => array(), | ||
| 'all_cached' => false, | ||
| 'all_expanded' => false, |
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.
Why would you cache non-expanded developer objects? That is just an other complexity that you have to deal with. Developer cache should contain only fully loaded developer objects.
Also, if you would like to use a complex structure like this for static cache I'd rather recommend you to create an object for that and instead of this array. It is not just complicated to work with an array, but also can cause performance degradation.
https://steemit.com/php/@crell/php-use-associative-arrays-basically-never
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.
Also, are you sure that we should introduce the static cache in the PHP SDK level not just in the Drupal 7 module? I do not know how many 3rd party apps relies on the V1 SDK but maybe we could handle this performance problem only in the Drupal 7 module. Therefore we would only need to deal with possible problems (bugs) that these changes may introduce in one place instead of two.
(Just an idea.)
PS.: I haven't implemented static caching in the V2 PHP API client, because if consumer apps needs that they can easily add that and after that they have to deal with the cache invalidation problem. ;) Besides the V1 SDK becomes deprecated sooner or later thanks for the new https://github.com/apigee/apigee-client-php.
Related PR: https://github.com/apigee-internal/devportal-profile/pull/568