org.infinispan.loaders.jdbc.mixed
public class JdbcMixedCacheStore extends org.infinispan.loaders.AbstractCacheStore
JdbcBinaryCacheStore
and JdbcStringBasedCacheStore
. It
aggregates an instance of JdbcBinaryCacheStore and JdbcStringBasedCacheStore, delegating work to one of them
(sometimes both, see below) based on the passed in key. In order to determine which store to use it will rely on the
configured Key2StringMapper
)(see configuration).
The advantage it brings is the possibility of efficiently storing string(able) keyed InternalCacheEntry
s, and at the same time being able to store any other keys, a la
JdbcBinaryCacheStore
.
There will only be a performance cost for the aggregate operations: loadAll, fromStream, toStream and clear. For
these operations there will be two distinct database call, one for each JdbcStore implementation. Most of application
are only using these operations at lifecycles changes (e.g. fromStream and toStream at cluster join time, loadAll at
startup for warm caches), so performance drawback shouldn't be significant (again, most of the cases).
Resource sharing - both aggregated cache loaders have locks and connection pools. The locking is not shared, each
loader keeping its own StripedLock
instance. Also the tables (even though
similar as definition) are different in order to avoid key collision. On the other hand, the connection pooling is a
shared resource.JdbcMixedCacheStoreConfig
,
JdbcBinaryCacheStore
,
JdbcStringBasedCacheStore
Constructor and Description |
---|
JdbcMixedCacheStore() |
Modifier and Type | Method and Description |
---|---|
void |
clear() |
void |
fromStream(ObjectInput inputStream) |
JdbcBinaryCacheStore |
getBinaryCacheStore() |
Class<? extends org.infinispan.loaders.CacheLoaderConfig> |
getConfigurationClass() |
ConnectionFactory |
getConnectionFactory() |
JdbcStringBasedCacheStore |
getStringBasedCacheStore() |
void |
init(org.infinispan.loaders.CacheLoaderConfig config,
org.infinispan.Cache<?,?> cache,
org.infinispan.marshall.StreamingMarshaller m) |
Set<org.infinispan.container.entries.InternalCacheEntry> |
load(int numEntries) |
org.infinispan.container.entries.InternalCacheEntry |
load(Object key) |
Set<org.infinispan.container.entries.InternalCacheEntry> |
loadAll() |
Set<Object> |
loadAllKeys(Set<Object> keysToExclude) |
protected void |
purgeInternal() |
boolean |
remove(Object key) |
void |
start() |
void |
stop() |
void |
store(org.infinispan.container.entries.InternalCacheEntry ed) |
void |
toStream(ObjectOutput outputStream) |
applyModifications, commit, getCacheStoreConfig, getConcurrencyLevel, getMarshaller, prepare, purgeExpired, removeAll, rollback, safeClose, safeClose, supportsMultiThreadedPurge
public void init(org.infinispan.loaders.CacheLoaderConfig config, org.infinispan.Cache<?,?> cache, org.infinispan.marshall.StreamingMarshaller m) throws org.infinispan.loaders.CacheLoaderException
init
in interface org.infinispan.loaders.CacheLoader
init
in class org.infinispan.loaders.AbstractCacheStore
org.infinispan.loaders.CacheLoaderException
public void start() throws org.infinispan.loaders.CacheLoaderException
start
in interface org.infinispan.loaders.CacheLoader
start
in class org.infinispan.loaders.AbstractCacheStore
org.infinispan.loaders.CacheLoaderException
public void stop() throws org.infinispan.loaders.CacheLoaderException
stop
in interface org.infinispan.loaders.CacheLoader
stop
in class org.infinispan.loaders.AbstractCacheStore
org.infinispan.loaders.CacheLoaderException
protected void purgeInternal() throws org.infinispan.loaders.CacheLoaderException
purgeInternal
in class org.infinispan.loaders.AbstractCacheStore
org.infinispan.loaders.CacheLoaderException
public org.infinispan.container.entries.InternalCacheEntry load(Object key) throws org.infinispan.loaders.CacheLoaderException
org.infinispan.loaders.CacheLoaderException
public Set<org.infinispan.container.entries.InternalCacheEntry> loadAll() throws org.infinispan.loaders.CacheLoaderException
org.infinispan.loaders.CacheLoaderException
public Set<org.infinispan.container.entries.InternalCacheEntry> load(int numEntries) throws org.infinispan.loaders.CacheLoaderException
org.infinispan.loaders.CacheLoaderException
public Set<Object> loadAllKeys(Set<Object> keysToExclude) throws org.infinispan.loaders.CacheLoaderException
org.infinispan.loaders.CacheLoaderException
public void store(org.infinispan.container.entries.InternalCacheEntry ed) throws org.infinispan.loaders.CacheLoaderException
org.infinispan.loaders.CacheLoaderException
public void fromStream(ObjectInput inputStream) throws org.infinispan.loaders.CacheLoaderException
org.infinispan.loaders.CacheLoaderException
public void toStream(ObjectOutput outputStream) throws org.infinispan.loaders.CacheLoaderException
org.infinispan.loaders.CacheLoaderException
public boolean remove(Object key) throws org.infinispan.loaders.CacheLoaderException
org.infinispan.loaders.CacheLoaderException
public void clear() throws org.infinispan.loaders.CacheLoaderException
org.infinispan.loaders.CacheLoaderException
public Class<? extends org.infinispan.loaders.CacheLoaderConfig> getConfigurationClass()
public ConnectionFactory getConnectionFactory()
public JdbcBinaryCacheStore getBinaryCacheStore()
public JdbcStringBasedCacheStore getStringBasedCacheStore()
Copyright © 2013 JBoss, a division of Red Hat. All Rights Reserved.