-
Notifications
You must be signed in to change notification settings - Fork 80
SITES-21278: Adds Invalidation for in-memory & dispatcher cache #1023
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
* governing permissions and limitations under the License. | ||
* | ||
******************************************************************************/ | ||
package com.adobe.cq.commerce.core.cacheInvalidation.internal; |
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.
Let's use lowercase package names: cacheinvalidation
* sonar fixes * osgi config * Test class * formatting code * SITES-21278: Adds the required method * sonar fixes for flush method * SITES-21278: Register the listener based on folder property * SITES-21278: Adds config for dispatcher impl * removing of osgi config code --------- Co-authored-by: Alwin Joseph <aljoseph@adobe.com>
* updated cif ask api version
contentType: 'application/json', | ||
data: JSON.stringify({ storePath: storePath }), | ||
success: function() { | ||
showDialog(Granite.I18n.get('Cache cleared successfully!')); |
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 would provide a better user experience to use dialog variants here.
See https://developer.adobe.com/experience-manager/reference-materials/6-5/coral-ui/coralui3/Coral.Dialog.html
For success message use the success variant.
showDialog(Granite.I18n.get('Cache cleared successfully!')); | ||
}, | ||
error: function() { | ||
showDialog(Granite.I18n.get('Failed to clear cache!')); |
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.
For error use the error dialog variant.
}, | ||
footer: { | ||
innerHTML: | ||
'<button is="coral-button" variant="primary" coral-close>' + Granite.I18n.get('OK') + '</button>' |
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.
For error dialog it would work better to have a 'Close' button instead of an 'OK' button.
jcr:primaryType="nt:unstructured" | ||
sling:resourceType="granite/ui/components/coral/foundation/button" | ||
text="Clear Cache" | ||
variant="primary" |
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 would suggest variant="secondary" to look more like the "cancel" button in the action bar rather than the primary "save&close" button.
jcr:primaryType="nt:unstructured" | ||
sling:resourceType="core/cif/components/renderconditions/pagetype" | ||
pageType="landing"/> | ||
<granite:rendercondition |
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.
If you check in crx/de these two granite:rendercondition nodes are merged into one node in the repo in an inappropriate way. Each sibling node should have a distinct name. Please use one node only and use the predefined 'and' or 'or' render conditions (like at "magentoSection" further down in this .content.xml) which support multiple render conditions as child nodes and perform a boolean operation on them.
"sling.servlet.methods=GET", | ||
"sling.servlet.extensions=html" | ||
}) | ||
public class InvalidateCacheButtonServlet extends SlingSafeMethodsServlet { |
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.
Let's name this ClearCacheButtonRenderConditionServlet.
}) | ||
public class InvalidateCacheButtonServlet extends SlingSafeMethodsServlet { | ||
|
||
public static final String RESOURCE_TYPE = "core/cif/components/renderconditions/dispatcherConfigCondition"; |
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.
Use "core/cif/components/renderconditions/clearcachebutton".
protected void doGet(@Nonnull SlingHttpServletRequest request, @Nonnull SlingHttpServletResponse response) { | ||
boolean conditionMet = invalidateCacheSupport != null; | ||
if (!conditionMet) { | ||
LOGGER.error("InvalidateCacheSupport service is not available"); |
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.
Avoid logging error here. This is normal if a customer is not using this feature and it's not enabled.
package com.adobe.cq.commerce.core.cacheinvalidation.spi; | ||
|
||
import org.osgi.annotation.versioning.ConsumerType; | ||
|
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.
Add javadoc for this interface.
|
||
@ConsumerType | ||
public interface CacheInvalidationStrategy { | ||
String getPattern(); |
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.
Add javadoc for this method.
|
||
import com.day.cq.wcm.api.Page; | ||
|
||
@ConsumerType |
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.
Please add javadoc for this interface and all its methods.
private InvalidateCacheRegistry invalidateCacheRegistry; | ||
|
||
public void invalidateCache(String path) { | ||
// To Do: Change this to for non-author run modes |
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.
Is this comment consistent with the code?
@alwinjoseph02 , great work so far! |
No description provided.