[id='local-{context}']
= Local Caches
While {brandname} is particularly interesting in clustered mode, it also offers a very
capable local mode.
In this mode, it acts as a simple, in-memory data cache similar to a `ConcurrentHashMap`.

But why would one use a local cache rather than a map?
Caches offer a lot of features over and above a simple map, including write-through and
write-behind to a persistent store, eviction of entries to prevent running out of memory,
and expiration.

{brandname}'s `Cache` interface extends JDK's `ConcurrentMap` -- making migration from a
map to {brandname} trivial.

{brandname} caches also support transactions, either integrating with an existing
transaction manager or running a separate one.
Local caches transactions have two choices:

1. When to lock?
*Pessimistic locking* locks keys on a write operation or when the user calls
`AdvancedCache.lock(keys)` explicitly.
*Optimistic locking* only locks keys during the transaction commit, and instead it throws
a `WriteSkewCheckException` at commit time, if another transaction modified the same keys
after the current transaction read them.

2. Isolation level.
We support *read-committed* and *repeatable read*.
