After looking at your examples it's a bit more code than I though.
Currently I'm using EHCache the non-EE way, but the code is a lot simpler.
I have a common singleton bean create the cache:

            // Create Ehcache cache manager
            cacheManager = CacheManager.create(config.getString(
                    "cacheConfigFile"));
            // Get the instance of "some-cache"
            cache = cacheManager.getCache(config.getString("cacheName"));

Then is a simple matter of:

        if (cache.get(accountId) != null) {
            log.debug(String.format("Account ID in cache: %s", accountId));
            retCustStbDto = (CustStbDto)
cache.get(accountId).getObjectValue();
        } else {
            Get the value to cache and cache...
        }

Now you are sprinkling this if/then logic throughout which is a code smell,
but it's more concise. Most of the example JCache code out there is based
on older artifacts.

This looks interesting
https://github.com/ehcache/ehcache-jcache/tree/master/ehcache-jcache


On Tue, Aug 18, 2015 at 11:21 AM, Romain Manni-Bucau <[email protected]>
wrote:

> Wrote a bit on it as well: https://rmannibucau.wordpress.com/tag/jcache/
>
> I still have a draft about annotations, surely time to finish it ;)
> Le 18 août 2015 08:04, "Jonathan Gallimore" <[email protected]> a
> écrit :
>
> > Here's demo I did using Hazelcast, JCache and CDI:
> > https://www.youtube.com/watch?v=-8tam4Rbxv0&app=desktop, in case its any
> > help.
> >
> > Regards
> >
> > Jon
> >
> > On Tue, Aug 18, 2015 at 3:56 PM, Howard W. Smith, Jr. <
> > [email protected]> wrote:
> >
> > > Steve,
> > >
> > > On Tue, Aug 18, 2015 at 10:38 AM, Steve Goldsmith <[email protected]>
> > > wrote:
> > >
> > > > Are there any good examples? I'll promise to add it my test project
> on
> > > > Github, so others can benefit as well.
> > > >
> > >
> > > I like how you share code for others to benefit, and I love TomEE (user
> > > list) just as well!
> > >
> > > I searched google for
> > >
> > > jcache tutorial java
> > >
> > > and found the following:
> > >
> > > https://cloud.google.com/appengine/docs/java/memcache/usingjcache
> > >
> > > https://dzone.com/articles/introduction-jcache-jsr-107
> > >
> > >
> > >
> >
> https://abhirockzz.wordpress.com/2015/02/09/sneak-peek-into-the-jcache-api-jsr-107/
> > >
> > > hope that helps.
> > >
> >
> >
> >
> > --
> > Jonathan Gallimore
> > http://twitter.com/jongallimore
> > http://www.tomitribe.com
> >
>



-- 
Steven P. Goldsmith

Reply via email to