GigaSpaces Online Help
The space can load data from external data sources , store data into external data sources, and persist its data into a relational database or an indexed file.
Persistency provides recoverability and unlimited capacity for a single space configuration. In general, persistency works like this: the persistent space uses files on disk or database to extend the physical memory boundaries of the process running the space. When searching for desire entries, the space uses both its process memory (cache) and its persistent media files. When the space is restarted, data from its persistent media files can be loaded into the space cache to speed up incoming query processing. The space can also be used as a Hibernate or JDO cache implementation via a Hibernate or JDO cache plug-in provided as part of GigaSpaces distribution.
GigaSpaces provide the following options when interacting with RDBMS:
JDBC SA- Persist any space operation into RDBMS when the mapping into the database tables done using classic class to table approach. The data within the database owned by GigaSpaces and should not be modified by external applications. You may access it directly via database tools or database API in read-only mode only. If you will modify the tables data directly , the space entries will not reflect these changes. You may use any RDBMS with JDBC driver with this option.
CacheStore/CacheLoader - Persist the space data into a RDBMS using your own database model – In this case when you write an entry to the space the CacheStore.store() method will be called in a class that implements the CacheStore interface. Here you can store the object content into the database. When you will try to read data from the space and the relevant entry with the specified UID does not exists within the space the CacheLoader.load() method will be called that will allow you to retrieve the relevant data based on some key from the database back into the space that will return it to the client. The generated object will be cached within the space and subsequent read to this object will be served by the space and return it back to the caller. This option is supported using the Java Map API (not via C# and C++ Map API) and also for with the JavaSpaces API (Java, C# and C++) with some limitations.
Hibernate Cache Plug-in – Here you access the space via Hibernate API where Hibernate query results and data is saved within the space. Repeated query result will be fetched from the space and not from the database.
CacheStore/CacheLoader based on Hibernate API – CacheStore/CacheLoader implementation based on Hibernate API where you will be able to map the space entries to database tables using Hibernate config files.
When you need to load data into the space at the beginning of day and later save it back to the database at the end of the day you may use the following options :
Use GigaSpaces JDBC driver - Here you will read the data from your database and write it to the space using GigaSpaces JDBC driver. Please note data written via the GigaSpaces JDBC driver may be accessed as ExternalEntry object and used by the JavaSpace API as any other entry. Your loader application will have 2 JDBC drivers connections - one with the RDBMS and another with GigaSpaces.
Use GigaSpaces JavaSpaces API + ORM - Here you will need to read the data from the RDBMS and map it to entries via some ORM tool (Hibernate) and write these to the space as Entry objects. At the end of the day you will read these from the space using GSIterator and write back to the RDBMS.
See below Database Cache and Persistency sections: