javamemcachedsimple-spring-memcachedssm

how to cache collection or array parameters with simple-spring-memcache


My project use a simple-spring-memcache to caching a service method, but it does't work, as follows:

@ReadThroughSingleCache(namespace = "AdvServiceImpl.findByIdList", expiration = 60)
public List<Adv> findByIdList(@ParameterValueKeyProvider(order = 0) List<String> idList, @ParameterValueKeyProvider(order = 1) String deviceType, @ParameterValueKeyProvider(order = 2) String sourceId) throws Exception {

But I write so it can work:

@ReadThroughSingleCache(namespace = "AdvServiceImpl.findByIdList", expiration = 60)
public List<Adv> findByIdList(List<String> idList, @ParameterValueKeyProvider(order = 0) String deviceType, @ParameterValueKeyProvider(order = 1) String sourceId) throws Exception {

Solution

  • @ReadThroughSingleCache shouldn't be used if one of the method's arguments annotated with ParameterValueKeyProvider is of type List. Instead of @ReadThroughSingleCache try to use @ReadThroughMultiCache