Skip to content

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

Merged
merged 44 commits into from
Feb 17, 2025

Conversation

alwinjoseph02
Copy link
Collaborator

No description provided.

@alwinjoseph02 alwinjoseph02 requested a review from LSantha December 3, 2024 11:09
* governing permissions and limitations under the License.
*
******************************************************************************/
package com.adobe.cq.commerce.core.cacheInvalidation.internal;
Copy link
Collaborator

@LSantha LSantha Dec 3, 2024

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

alwinjoseph02 and others added 27 commits December 10, 2024 22:21
* 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!'));
Copy link
Collaborator

@LSantha LSantha Feb 13, 2025

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!'));
Copy link
Collaborator

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>'
Copy link
Collaborator

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"
Copy link
Collaborator

@LSantha LSantha Feb 13, 2025

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
Copy link
Collaborator

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 {
Copy link
Collaborator

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";
Copy link
Collaborator

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");
Copy link
Collaborator

@LSantha LSantha Feb 13, 2025

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;

Copy link
Collaborator

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();
Copy link
Collaborator

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
Copy link
Collaborator

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.

@alwinjoseph02 alwinjoseph02 marked this pull request as ready for review February 14, 2025 12:08
private InvalidateCacheRegistry invalidateCacheRegistry;

public void invalidateCache(String path) {
// To Do: Change this to for non-author run modes
Copy link
Collaborator

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?

@LSantha
Copy link
Collaborator

LSantha commented Feb 17, 2025

@alwinjoseph02 , great work so far!

@LSantha LSantha merged commit ce1c6ac into master Feb 17, 2025
19 checks passed
@LSantha LSantha deleted the feature/SITES-21278 branch February 17, 2025 11:15
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.

3 participants