AArhin / simple-spring-memcached

Automatically exported from code.google.com/p/simple-spring-memcached
MIT License
0 stars 0 forks source link

CacheValueMethod #26

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago

   I am using 3rd party client domain objects which are restricted to modification. What I would like to is a mechanism to convert serialized objects to another one. Let me to give you an example:

   @CacheValueMethod(convertor="VideoConvertor")
   @Cacheable(value = "defaultCache#600", key = "'cemo'")
   @Override
   public VideoInfo getVideoByTagId(List<Long> params) {
      return videoDAO.getVideoByTagId(params);
   }

Here I would like to store videoId instead of VideoInfo. A convertor might be a 
bean as well. Guava project has a similar converter [1].

[1]: com.google.common.base.Converter 

Original issue reported on code.google.com by cemalettin.koc@gmail.com on 23 Jan 2014 at 9:37

GoogleCodeExporter commented 9 years ago
I don't think that we should modify behavior of Cacheable annotation because 
it's not a part of SSM but Spring. If you want such feature you should request 
it from Spring team then SSM will support it out of the box.
In raw SSM there is a workaround. You can use SerializationType.CUSTOM and 
register custom cache transcoder using CacheFactory. In the transcoder you can 
define how to serialize and deserialize objects of given type.

Original comment by ragno...@gmail.com on 23 Jan 2014 at 1:12

GoogleCodeExporter commented 9 years ago
Thank you so much. This is exactly what I need :) 

Original comment by cemalettin.koc@gmail.com on 23 Jan 2014 at 2:04

GoogleCodeExporter commented 9 years ago
Great! I'll close the issue. If you find any issues with the 
SerializationType.CUSTOM please let me know and open another issue.

Original comment by ragno...@gmail.com on 24 Jan 2014 at 9:11