Can I specify expiry time in @Cacheable?

4,516 views
Skip to first unread message

kishore....@gmail.com

unread,
Dec 12, 2013, 5:32:55 AM12/12/13
to simple-sprin...@googlegroups.com

Hi all,

I am setting my cache expiration time as follows

<bean class="org.springframework.web.servlet.view.BeanNameViewResolver" />
   
         <bean name="cacheManager" class="com.google.code.ssm.spring.SSMCacheManager">
        <property name="caches">
            <set>
                <bean class="com.google.code.ssm.spring.SSMCache">
                    <constructor-arg name="cache" index="0" ref="defaultCache"/>
                    <constructor-arg name="expiration" index="1" value="120"/>
                    <constructor-arg name="allowClear" index="2" value="false"/>
                </bean>
            </set>
        </property>

    </bean>

Can I specify expiry time along with @Cacheable?

Thanks in advance,
Kishor

Jakub Białek

unread,
Dec 12, 2013, 5:49:03 AM12/12/13
to simple-sprin...@googlegroups.com
Hi,

Yes, you can. Instead of com.google.code.ssm.spring.SSMCacheManager use com.google.code.ssm.spring.ExtendedSSMCacheManager. Here you can find details: custom expiration time
The usage is simple, the expire time can be specified in value field after # character. In below example the expire time is 600s. If custom expire time is not provided a default configured along with ExtendedSSMCacheManager is used.
@Cacheable(value = "YourCacheName#600", key = "#your_key") 

Best regards,

-- Ragnor


--
You received this message because you are subscribed to the Google Groups "simple-spring-memecached" group.
To unsubscribe from this group and stop receiving emails from it, send an email to simple-spring-meme...@googlegroups.com.
To post to this group, send email to simple-sprin...@googlegroups.com.
Visit this group at http://groups.google.com/group/simple-spring-memecached.
For more options, visit https://groups.google.com/groups/opt_out.

kishor sivan

unread,
Dec 12, 2013, 6:18:23 AM12/12/13
to simple-sprin...@googlegroups.com
Thanks Ragnor.. it worked.

Regards,
Kishor
To unsubscribe from this group and stop receiving emails from it, send an email to simple-spring-memecached+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages