0

I am using caching annotations of Spring. I want to pass name of Cache [@CacheEvict(name="vendorCache")] from applicationContextfile or it can be configured in any other way.

Now i have scenario in which i have two classes VendorDAo and NetworkDao.

public VenderDAO
{
@CacheEvict(name="vendorCache")
public String insert():void
{
    //code to add the record into the table using ibatis
}
}


public NetworkDao
{
@CacheEvict(name="netWorkCache")
public String insert():void
{
    //code to add the record into the table using ibatis
}
}

Now i have few more methods but the only difference is that @CacheEvict. Is there any way such that i can declare cache name in the configuration file and pass to bean as property.

<bean id="venderDAO" class="VenderDAO">
<property name="cachename" value="vendorCache"/>
</bean>

<bean id="netWorkDAO" class="VenderDAO">
<property name="cachename" value="netWorkCache"/>
</bean>

[Note: both the beans have the same class name]

and can use this in java file Or there is any other way. Any pointers will be highly appreciated.

Regards

Raj

1 Answers1

0

Spring cache abstraction is only available through annotations (@Cacheable and @CacheEvict) on methods you need to cache. You cannot use XML declaration. 27. Cache Abstraction

Benoit Wickramarachi
  • 6,096
  • 5
  • 36
  • 46