Understaning DataSource Flow

Simplified Data Access

Cacheonix working as an in-memory data grid significantly simplifies access to application data by providing the DataSource API that isolates the details of how the data is retrieved from external back-end data sources. When an implementation of DataSource is configured for a cache, all the application has to do to get the data it needs is to request a key from the cache. Cacheonix will automatically invoke the DataSource implementation to perform application-specific actions such as reading the data from a database. Cacheonix places the data in the cache and continues to serve it from memory while adhering to configured expiration and eviction parameters. The diagrams below provide a high-level overview of what is going on when application requests a key that is not in the cache (cache miss).

DataSource Sequence Diagram

DataSource Communication Diagram

Configuring Cache Data Source

To be able to access the back-end data automatically, implement interface cacheonix.cache.datasource.DataSource.

Classes implementing cacheonix.cache.datasource.DataSource must provide a public un-protected no-argument onstructor.

Configure the cache data source by adding dataSource element to the cache configuration:

<partitionedCache name="property.cache">
        <lru maxElements="10" maxBytes="10mb"/>
        <expiration timeToLive="1s"/>

        <dataSource className="example.PropertyCacheDataSource"/>


Check an example of an implementation of cacheonix.cache.datasource.DataSource.