grails / grails-redis

Base redis plugin for Grails

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Missing redisService.memoizeObject() method

mrnohr opened this issue · comments

There is a @MemoizeObject annotation used to memoize simple (non-domain) classes. However, there is not a corresponding redisService.memoizeObject() method.

I really am looking for a way to memoize objects against different redis servers. I was hoping to be able to do something like:

redisServiceCache.memoizeObject("key", [expire: 3600, clazz: MyObject.class])

An alternative would be to allow the redis server from the annotation.

@mrnohr I want to make sure that I'm understanding what you're asking for. How I understand what you're saying is that you've got multiple distinct redis instances (so not clustered together) and you want to use the annotations (which by default just go at the "main" redisService) against those other connections instead of the default one. Ones that you can get spring injected into your Grails services with names like redisServiceCache.

Alternatively, if the @MemoizeObject annotation had the corresponding memoizeObject method, you could make that work by just doing that inside your methods with the proper injected connection, but you'd prefer to use the annotation?

It felt like a miss to not have RedisService.memoizeObject and it turned out to be pretty simple to implement (I wasn't the one that originally did the @MemoizeObject annotation). Hopefully this fits with what you were looking for. It'll be in the next release of the plugin.

Just for completion in the history, I'll answer @tednaleid 's questions. Yes, my intent was to have multiple redis instances and be able to use the memoizeObject method. This was so I could scale up to use different redis servers for different types of objects.

Currently I am using the @MemoizeObject annotation, but with this change I can now switch to using the new memoizeObject method.

This fix will be a big help!

Looks good @tednaleid !