You can configure in-line caching for a database
back end
or as a side cache for a database. In-line caching uses eXtreme Scale as the primary means
for interacting with the data. When eXtreme Scale is used as an in-line
cache, the application interacts with the back end using a Loader
plug-in.
In-line
cache
When used as
an in-line cache,
WebSphere® eXtreme Scale interacts
with the back end using a Loader plug-in. This scenario can simplify
data access because applications can access the
eXtreme Scale APIs directly. Several
different caching scenarios are supported in
eXtreme Scale to make sure the
data in the cache and the data in the back end are synchronized.
The following diagram illustrates how an in-line cache interacts with
the application and back end.
The in-line caching
option simplifies data access because
it allows applications to access the eXtreme Scale APIs directly. WebSphere
eXtreme Scale supports several
in-line caching scenarios, as follows.
- Read-through
- Write-through
- Write-behind
Read-through
caching scenario
A read-through
cache is a sparse cache that lazily loads data entries by key as they
are requested. This is done without requiring the caller to know how
the entries are populated. If the data cannot be found in the
eXtreme Scale cache,
eXtreme Scale will retrieve the
missing data from the Loader plug-in, which loads the data from the
back-end database and inserts the data into the cache. Subsequent
requests for the same data key will be found in the cache until it
is removed, invalidated or evicted.
Figure 2. Read-through caching
Write-through caching scenario
In
a write-through
cache, every write to the cache synchronously writes to the database
using the Loader. This method provides consistency with the back end,
but decreases write performance since the database operation is synchronous.
Since the cache and database are both updated, subsequent reads for
the same data will be found in the cache, avoiding the database call.
A write-through cache is often used in conjunction with a read-through
cache.
Figure 3. Write-through caching
Write-behind
caching scenario
Database synchronization
can be improved by writing changes asynchronously. This is known as
a write-behind or write-back cache. Changes that would normally be
written synchronously to the loader are instead buffered in
eXtreme Scale and written to the
database using a background thread. Write performance is significantly
improved because the database operation is removed from the client
transaction and the database writes can be compressed.
Figure 4. Write-behind
caching