Cache Invalidation Sample Code Smart way to Invalidate Cache
Create a new Class 'MyRepository' extending ATG’s GSARepository.
Create an Instance variable to decide whether do we need to invalidate the Cache or Not ? Initialize it with true.
private boolean mInvalidateCaches = true;
Override invalidateCaches() method of ‘GSARepository’, inside this method call the super class method super.invalidateCaches(),only
if ‘invalidateCaches’ Variable is set to true,and this is
variable is set from the Versioned Repository component.
Configure Repositories, which are taking part in Versioning
with invalidateCaches=false. This will prevent ATG to invalidate Cache automatically when assets of that repositories are getting deployed.
public void invalidateCaches(){
if(isInvalidateCaches()){
super.invalidateCaches();
}
}
Because we have Overridden invalidateCaches() method in MyRepository class, it will invalidate Cache only if invalidateCaches=true, ATG will not be invalidating the Cache automatically after every Deployment.
Now if you want to see the deployed changes on target, we have to manually invoke invalidateCaches() method using Admin UI, which can be done during off peak hours, so that site performance will not be compromised.
Modify your Versioned Repositories like below.
eg: /atg/commerce/catalog/ProductCatalog.properties
$class=com.mycompany.common.cache.MyRepository
dataSource=/atg/dynamo/service/jdbc/JTDataSourceA
invalidateCaches=false
Create an Instance variable to decide whether do we need to invalidate the Cache or Not ? Initialize it with true.
private boolean mInvalidateCaches = true;
Override invalidateCaches() method of ‘GSARepository’, inside this method call the super class method super.invalidateCaches(),only
if ‘invalidateCaches’ Variable is set to true,and this is
variable is set from the Versioned Repository component.
Configure Repositories, which are taking part in Versioning
with invalidateCaches=false. This will prevent ATG to invalidate Cache automatically when assets of that repositories are getting deployed.
public void invalidateCaches(){
if(isInvalidateCaches()){
super.invalidateCaches();
}
}
Because we have Overridden invalidateCaches() method in MyRepository class, it will invalidate Cache only if invalidateCaches=true, ATG will not be invalidating the Cache automatically after every Deployment.
Now if you want to see the deployed changes on target, we have to manually invoke invalidateCaches() method using Admin UI, which can be done during off peak hours, so that site performance will not be compromised.
Modify your Versioned Repositories like below.
eg: /atg/commerce/catalog/ProductCatalog.properties
$class=com.mycompany.common.cache.MyRepository
dataSource=/atg/dynamo/service/jdbc/JTDataSourceA
invalidateCaches=false
Comments
Post a Comment