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

Ask Your Question
0

Example of cache and persitency

Hi,

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?

Hadrien

{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 gravatar image

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

jaissefsfex gravatar image
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

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:
http://www.gigaspaces.com/wiki/display/GS6/OpenSpacesPersistencyScenarios-ExternalDataSource

http://www.gigaspaces.com/docs/JavaDoc6/com/gigaspaces/datasource/ExternalDataSource.html

Cheers,
Guy

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

nirpaz gravatar image
edit flag offensive delete link more

Comments

See more doc at:
http://www.gigaspaces.com/wiki/display/GS6/JavaSpacesAPIWrite-Through-6.0
http://www.gigaspaces.com/wiki/display/GS6/JavaSpacesAPIRead-Through-6.0

Full example (part of the examples package) located at:
\GigaSpacesXAP6.0\examples\Advanced\Data_Grid\Database-Integration\JdbcDataSource

Shay

shay hassidim gravatar imageshay 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?)

Hadrien

htexier gravatar imagehtexier ( 2008-05-07 04:41:47 -0500 )edit

Hi,

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.

Guy

nirpaz gravatar imagenirpaz ( 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:
space-config.engine.initial_load=70

- 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:
http://www.gigaspaces.com/wiki/display/GS6/Read-ThroughandWrite-ThroughinClusteredSpace-6.0

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

Shay

shay hassidim gravatar imageshay 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

Stats

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

Seen: 64 times

Last updated: May 05 '08