Welcome to the new Gigaspaces XAP forum. To recover your account, please follow these instructions.

Ask Your Question

Example of cache and persitency


I'm looking for an example or a tutorial about the using of a cache based on a existing database. I wish to integrate an existing database. Is there another way to create a cache without to use Hibernate? I wish to use simple DAOs. According the overview about "Database Cache and Persistency Overview - 6.0", the IStorageAdapter interface is used but I don't see it in the API. I wish to work directly with the memory, without being aware of the database. If the data isn't in the cache, how can I configure GigaSpaces so that the cache gets the (new for the cache) data from the database? Which interface have I to implement? Is it possible to initialize the cache?

Have you some pieces of advice, please?


{quote}This thread was imported from the previous forum. For your reference, the original is [available here|http://forum.openspaces.org/thread.jspa?threadID=1885]{quote}

asked 2008-05-05 12:20:30 -0500

htexier's avatar

updated 2013-08-08 09:52:00 -0500

jaissefsfex's avatar
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

Hello Hadrien,

The External Data Source is the way to integrate with existing data sources.
A Hibernate External Data Source is coming with the product; however, you can implement your own implementation by using DAO.

There are two options where you can work with:
1. All In Cache - where the data is loaded into memory during system initialization
2. LRU - Data is loaded on demand

Here are some pointers:



answered 2008-05-05 13:39:21 -0500

nirpaz's avatar
edit flag offensive delete link more


See more doc at:

Full example (part of the examples package) located at:


shay hassidim's avatar shay hassidim  ( 2008-05-05 19:04:41 -0500 )edit

Thx Guy and Shay, the example is perfect! It is a great help for me!

I have still 2 groups of questions: - Who calls the init method of the JdbcDataSource class? - How is the cache initialized? Is it with the read/write operations or is it possible to initialize the cache? Could this init method allow to initialize the cache? (I killed the primary space so that the data are always available. This action is deleted the data of the database. I suppose that the init method has been called by the backup space, doesn't it?)


htexier's avatar htexier  ( 2008-05-07 04:41:47 -0500 )edit


Cache is initialized based on the space toplogy. When using All-In-Cahce the primary space is initialized first using the 'initialLoad' method of the EDS. The backup space is initialized by recovering it's state from the primary space. In this case, the backup's initialLoad method is never called.


nirpaz's avatar nirpaz  ( 2008-05-08 15:49:14 -0500 )edit

Please note that:
- With ALLINCACHE cache policy mode the space will load whatever you will feed into it via the ExternalDataSource.initialLoad() method. Be careful here no to load too much.

- When running in LRU cache policy mode the space will load 50 % of the amount of objects specified as part of the cache size parameter you will feed into it via the ExternalDataSource.initialLoad() method.

- You can control the 50 % using the space-config.engine.initial_load parameter.
For example - if you want to load 70 % of the loaded objects you should have:

- When running a space with ExternalDataSource and you run a backup space in shared data source mode - write operations would not be replicated.

- When running a space with ExternalDataSource and you run a backup space in a non shared data source mode - write operations would be replicated.

- In both cases (shared and non shared data source) - loaded data (in case of cache miss in LRU mode as part of read operations) would not be replicated.

See more here:

In most cases we recommend to run in ALLINCACHE mode , loading all data once the space started , avoiding cache misses.


shay hassidim's avatar shay hassidim  ( 2008-05-12 21:50:56 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2008-05-05 12:20:30 -0500

Seen: 100 times

Last updated: May 05 '08