Camel-Cache 2.14.0 with MyBatis

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Camel-Cache 2.14.0 with MyBatis

sandp
Hi,
I'm trying to implement caching with camel-cache. The Idea is to cache the results of  a mybatis query on a table update. I'm looking at something that would automatically flush the cache for the key, run the mybatis query and cache its result again?

A restlet endpoint would look into the cache and produce a response.
Reply | Threaded
Open this post in threaded view
|

Re: Camel-Cache 2.14.0 with MyBatis

hekonsek
Hi,

> I'm looking at something that
> would automatically flush the cache for the key, run the mybatis query and
> cache its result again?

No such thing out of the box. You need to control the cache by
explicit calls to camel-cache operations. You can however consider
using interceptors [1] to partially automate such calls in the AOP
manner.

Cheers.

[1] http://camel.apache.org/intercept.html

--
Henryk Konsek
http://henryk-konsek.blogspot.com
Reply | Threaded
Open this post in threaded view
|

Re: Camel-Cache 2.14.0 with MyBatis

sandp
Hi,

If I controlled the cache by explicit calls to camel-cache operations, I wouldn't know if something changed unless I run the mybatis endpoint.

Traditional way is to have a trigger on the table, and listen to update on a row from the application or implement the Observer Pattern.

Having a trigger seems to be a  simple solution, but does camel provide a way to listen to a DB trigger?
Reply | Threaded
Open this post in threaded view
|

Re: Camel-Cache 2.14.0 with MyBatis

hekonsek
Hi,

> Having a trigger seems to be a  simple solution, but does *camel provide a
> way to listen to a DB trigger*?

You can use trigger to invoke Camel endpoint. For example in Postgres
you can write modules in PL/Python [1] and invoke HTTP Netty endpoint
exposed by Camel. Messages from that endpoint can be routed to
invalidate the cache.

Cheers.

[1] http://www.postgresql.org/docs/9.1/static/plpython-trigger.html

--
Henryk Konsek
http://henryk-konsek.blogspot.com