public class JdbcBinaryCacheStore extends BucketBasedCacheStore
BucketBasedCacheStore
implementation that will store all the buckets as rows in database, each row
corresponding to a bucket. This is in contrast to JdbcStringBasedCacheStore
which stores each StoredEntry as a row in the database.
It is generally recommended to use JdbcStringBasedCacheStore
whenever
possible as it performs better. Please read JdbcStringBasedCacheStore
's
javadoc for more details on this.
This class has the benefit of being able to store StoredEntries that do not have String keys, at the cost of coarser
grained access granularity, and inherently performance.
All the DB related configurations are described in .JdbcBinaryCacheStoreConfiguration
.JdbcBinaryCacheStoreConfiguration
,
JdbcStringBasedCacheStore
BucketBasedCacheStore.BucketHandler, BucketBasedCacheStore.CollectionGeneratingBucketHandler<T>
multiThreadedPurge, purgerService
cache, marshaller, timeService
Constructor and Description |
---|
JdbcBinaryCacheStore() |
Modifier and Type | Method and Description |
---|---|
protected void |
clearLockSafe() |
void |
doConnectionFactoryInitialization(ConnectionFactory connectionFactory)
Keeps a reference to the connection factory for further use.
|
protected void |
fromStreamLockSafe(ObjectInput objectInput) |
ConnectionFactory |
getConnectionFactory() |
protected StreamingMarshaller |
getMarshaller() |
TableManipulation |
getTableManipulation() |
void |
init(CacheLoaderConfiguration configuration,
Cache<?,?> cache,
StreamingMarshaller m)
Used to initialize a cache loader.
|
protected void |
insertBucket(Bucket bucket)
Inserts a new Bucket in the storage system.
|
Set<Object> |
loadAllKeys(Set<Object> keysToExclude)
Loads a set of all keys, excluding a filter set.
|
Set<InternalCacheEntry> |
loadAllLockSafe() |
protected Bucket |
loadBucket(Integer keyHashCode)
Loads a Bucket from the store, based on the hash code of the bucket.
|
protected Set<InternalCacheEntry> |
loadLockSafe(int maxEntries) |
protected void |
loopOverBuckets(BucketBasedCacheStore.BucketHandler handler)
A mechanism to loop over all buckets in the cache store.
|
void |
purgeInternal() |
void |
start() |
void |
stop() |
protected void |
toStreamLockSafe(ObjectOutput objectOutput) |
protected void |
updateBucket(Bucket bucket)
Updates a bucket in the store with the Bucket passed in to the method.
|
getLockFromKey, loadAllKeysLockSafe, loadLockSafe, removeLockSafe, storeLockSafe
acquireGlobalLock, clear, downgradeLock, fromStream, getTotalLockCount, immediateLockForWriting, load, load, loadAll, lockForReading, lockForWriting, releaseGlobalLock, remove, store, toStream, unlock, upgradeLock
applyModifications, commit, getConcurrencyLevel, getConfiguration, prepare, purgeExpired, removeAll, rollback, safeClose, safeClose, supportsMultiThreadedPurge
containsKey, validateConfigurationClass
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
containsKey
public void init(CacheLoaderConfiguration configuration, Cache<?,?> cache, StreamingMarshaller m) throws CacheLoaderException
CacheLoader
CacheLoaderManager
when setting up cache loaders.init
in interface CacheLoader
init
in class LockSupportCacheStore<Integer>
configuration
- the cache loader configuration beancache
- cache associated with this cache loader. Implementations may use this to determine cache name when
selecting where refer to state in storage, for example, a different database table name.m
- marshaller to use when loading state from a stream, if supported by the implementation.CacheLoaderException
public void start() throws CacheLoaderException
start
in interface CacheLoader
start
in class LockSupportCacheStore<Integer>
CacheLoaderException
public void stop() throws CacheLoaderException
stop
in interface CacheLoader
stop
in class AbstractCacheStore
CacheLoaderException
protected void insertBucket(Bucket bucket) throws CacheLoaderException
BucketBasedCacheStore
BucketBasedCacheStore.updateBucket(Bucket)
.insertBucket
in class BucketBasedCacheStore
bucket
- bucket to insertCacheLoaderException
- in case of problems with the store.protected void updateBucket(Bucket bucket) throws CacheLoaderException
BucketBasedCacheStore
BucketBasedCacheStore.insertBucket(Bucket)
as well so that it doesn't blindly
forward calls to BucketBasedCacheStore.updateBucket(Bucket)
.
updateBucket
in class BucketBasedCacheStore
bucket
- bucket to update.CacheLoaderException
- in case of problems with the store.protected Bucket loadBucket(Integer keyHashCode) throws CacheLoaderException
BucketBasedCacheStore
loadBucket
in class BucketBasedCacheStore
keyHashCode
- the Bucket's hashCacheLoaderException
- in case of problems with the store.public Set<InternalCacheEntry> loadAllLockSafe() throws CacheLoaderException
loadAllLockSafe
in class BucketBasedCacheStore
CacheLoaderException
public Set<Object> loadAllKeys(Set<Object> keysToExclude) throws CacheLoaderException
CacheLoader
loadAllKeys
in interface CacheLoader
loadAllKeys
in class LockSupportCacheStore<Integer>
keysToExclude
- a set of keys to exclude. An empty set or null will indicate that all keys should be returned.CacheLoaderException
protected Set<InternalCacheEntry> loadLockSafe(int maxEntries) throws CacheLoaderException
loadLockSafe
in class BucketBasedCacheStore
CacheLoaderException
protected void loopOverBuckets(BucketBasedCacheStore.BucketHandler handler) throws CacheLoaderException
BucketBasedCacheStore
BucketBasedCacheStore.BucketHandler.handle(Bucket)
returns true or there are no more buckets available.
loopOverBuckets
in class BucketBasedCacheStore
CacheLoaderException
protected void fromStreamLockSafe(ObjectInput objectInput) throws CacheLoaderException
fromStreamLockSafe
in class LockSupportCacheStore<Integer>
CacheLoaderException
protected void toStreamLockSafe(ObjectOutput objectOutput) throws CacheLoaderException
toStreamLockSafe
in class LockSupportCacheStore<Integer>
CacheLoaderException
protected void clearLockSafe() throws CacheLoaderException
clearLockSafe
in class LockSupportCacheStore<Integer>
CacheLoaderException
public void purgeInternal() throws CacheLoaderException
purgeInternal
in class AbstractCacheStore
CacheLoaderException
public ConnectionFactory getConnectionFactory()
public void doConnectionFactoryInitialization(ConnectionFactory connectionFactory) throws CacheLoaderException
TableManipulation
that needs connections. This method should be called when you don't
want the store to manage the connection factory, perhaps because it is using an shared connection factory: see
JdbcMixedCacheStore
for such an example of this.CacheLoaderException
public TableManipulation getTableManipulation()
protected StreamingMarshaller getMarshaller()
getMarshaller
in class AbstractCacheStore
Copyright © 2013 JBoss, a division of Red Hat. All Rights Reserved.