0

Thanks to the 'Getting started guide' in ‘simple-spring-memcached’ I manage to get memcached working in my project using ‘Spring 3.1’ example in in the guide , Im using ‘spymemcached’ as the provider . All working well when memcached server is up and running. However, when memcache server is not accessible (deliberately shut down for testing) underline code doesn’t work and application wont execute simply throwing runtime exception ,stating that unable to connect to memcache server and timeout happen .

Caused by: net.spy.memcached.internal.CheckedOperationTimeoutException: Timed out waiting

However what I expect in this scenario is to target method to be executed every time as cache is unreachable than completly blocking the execution path. Is this possible using simple spring memcache ? , has any one got experience with this ? how do I solve this situation , Any exception in cache layer no need to disturb the execution, simply need to call the target method as a fall-back. This is what I’m trying to achieve.

I tried spring ‘CompositeCacheManager’ with ‘fallbackToNoOpCache’ but it looks like simple-spring-memcached has no effect on this .

All my configuration is exactly similar to (spring 3.1 )

https://code.google.com/p/simple-spring-memcached/wiki/Getting_Started

Thanks for your help

eg : usage of my @Cacheable is

@Cacheable(value="books", key="#isbn")
public Book findBook(ISBN isbn, boolean checkWarehouse, boolean includeUsed)
ragnor
  • 2,498
  • 1
  • 22
  • 25
csf
  • 529
  • 1
  • 4
  • 16

1 Answers1

1

You are right it should work as you have described it and I'm sure that in case of SSM annotations (@ReadThrough*, @Update*, @Invalidate*) it works in that way. I see that for Spring Cache annotations the behavior is different . I'll try to fix it today. If you don't mind could you please create an issue for this bug on github SSM page.

ragnor
  • 2,498
  • 1
  • 22
  • 25
  • Thanks ragnor , Thanks for the quick response ,Brilliant job and appreciate your help. As you requested i have created the bug in above Page – csf Mar 12 '14 at 09:40
  • Also i found that If i use 'xmemcached' it works as expected . – csf Mar 12 '14 at 09:44
  • Brillient , i will try this and let you know . thanks and appriciate your quick response ! – csf Mar 14 '14 at 13:11
  • Similarily, running with the AWS implementation (com.google.code.ssm.providers.elasticache.MemcacheClientFactoryImpl) java.nio.channels.UnresolvedAddressException errors are thrown if the memcached cluster is unreachable. I would expect the underlying method to be called and just perhaps log a warning. Is that not how it should work? If not, is there a good way to fail gracefully if the cache server is unavailable? – clav Mar 22 '17 at 16:22
  • Isn't it logged by Spring? A cache is created by CacheFactory.getObject which implements FactoryBean. – ragnor Mar 23 '17 at 05:52