Re: [jcs] Migrating from Ehcache to JCS, need help getting the right config

2017-03-26 Thread Thomas Vandahl
On 23.03.17 15:01, robertlazarski . wrote:
> Thanks for the response! That helped a lot. I am about to start coding
> but I am trying to figure out #3. Please see below.

The cache warming itself is not a big deal. Just call getKeySet() on the
memory cache and call get() for all keys. This will load the values from
disk into the memory cache. The question is just where to insert the
loop into the application initialization.

Bye, Thomas


-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [jcs] Migrating from Ehcache to JCS, need help getting the right config

2017-03-23 Thread robertlazarski .
Thanks for the response! That helped a lot. I am about to start coding
but I am trying to figure out #3. Please see below.

On Wed, Mar 22, 2017 at 2:44 PM, Thomas Vandahl  wrote:
>> 3) Most importantly, on server startup we need the entire disk
>> persisted cache loaded into memory, i.e. "cache warming" . I am
>> wondering if the CacheLoaderAdapter is the right class for this?
>> Currently we use a class that Ehcache calls on startup that just uses
>> an Iterator over all the cache Elements, effectively loading
>> everything into memory.
>
> This can be achieved by setting ClearDiskOnStartup=false. This happens
> to be the default. JCS will load all the keys into memory then but not
> the values. So if you want the values to be loaded, just modify the
> class you used for EHCache.
>
> How to integrate this into your application depends on your application
> lifecycle. There is no CacheLoaderAdapter class in JCS. If you tell me a
> bit more about your application, I might be able to give you a hint.
>
> HTH
> Bye, Thomas
>

The CacheLoaderAdapter class I referred to as it turns out is for
JCache and its in the JCS extras module.

https://commons.apache.org/proper/commons-jcs//commons-jcs-jcache-extras/apidocs/org/apache/commons/jcs/jcache/extras/loader/CacheLoaderAdapter.html

The reason I was interested in this is because with ehcache I define
bootstrapCacheLoaderFactory=myStartUpClass that ehcache calls on
server init / ehcache init, as my class extends the ehcache
MemoryLimitedCacheLoader class to load the entire cache (keys and
values) into memory.

I am just looking for some way to do the equivalent with JCS - call
something on server init and perhaps tied in to JCS init. That led me
into JCache. Anyways we have a simple local cache I am trying to just
get JCS to somehow get my cache into memory on startup and then go
from there.

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [jcs] Migrating from Ehcache to JCS, need help getting the right config

2017-03-22 Thread Thomas Vandahl
Hi there,

On 21.03.17 15:50, robertlazarski . wrote:
> Hello! We have a production system running Ehcache and we'd like to
> use JCS instead. What I need to do with JCS is:
> 
> 1) Load all Objects into memory, unlimited with infinite "time to
> live". In practice over many years, its not been a problem for us.
> Currently using LRU.

Yes, this is easy, just define a memory cache big enough to hold all
your objects. Set

jcs.default.elementattributes.IsEternal=true

> 2) Store Objects from memory to disk on JVM shutdown, or at least
> periodically flush to disk - while keeping the entire cache in memory.

See
https://commons.apache.org/proper/commons-jcs/IndexedDiskAuxCache.html
for the configuration of an auxiliary disk cache. If you have configured
your memory cache big enough, no "overflow" of items to disk will happen
in normal operation.

You need to shut down the cache orderly
(CompositeCacheManager.getInstance().shutDown()) to trigger the "dump to
disk" process. There is no simple method to do this periodically.

> 
> 3) Most importantly, on server startup we need the entire disk
> persisted cache loaded into memory, i.e. "cache warming" . I am
> wondering if the CacheLoaderAdapter is the right class for this?
> Currently we use a class that Ehcache calls on startup that just uses
> an Iterator over all the cache Elements, effectively loading
> everything into memory.

This can be achieved by setting ClearDiskOnStartup=false. This happens
to be the default. JCS will load all the keys into memory then but not
the values. So if you want the values to be loaded, just modify the
class you used for EHCache.

How to integrate this into your application depends on your application
lifecycle. There is no CacheLoaderAdapter class in JCS. If you tell me a
bit more about your application, I might be able to give you a hint.

HTH
Bye, Thomas

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org