Create a CacheManager from a Configuration in an inputStream in ehcache3

95 views
Skip to first unread message

soccergods

unread,
Jul 22, 2020, 9:33:16 AM7/22/20
to ehcache-users
I am currently migrating from Ehcache2.8 to ehcache 3.8.1

In ehcache2, I used to store my ehcache properties externally and brought it into an input stream and then created a cache manager using it.

However, in ehcache3, I don't see such an option to build it using an inputStream which to me seems like a cool feature to have. Am I missing something? I tried using the ConfigurationBuilder, the CacheManagerBuilder and a bunch of things but none of them seem to accept input streams to do the configuration. I only see it possible using resources objects. My properties files are stored in the db for easy access and I would like to continue using the same if possible.

One potential solution I was thinking is that I would parse my external file and them do something like "createCache" xyz and do this for the number of caches present, but I feel like there should be a more optimal way to do the same. 

soccergods

unread,
Jul 24, 2020, 6:12:12 AM7/24/20
to ehcache-users
Found a way to do it in ehcache3 as well.

I used "org.w3c.dom.Document"


The gist is that I converted my input stream into a Document and then passed the document into the constructor of the XMLconfiguration object which can be used to set the configurations of the cachemanager in ehcache3
Reply all
Reply to author
Forward
0 new messages