Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.slide.util
Class ByteSizeLimitedObjectCache

    java.lang.Object
      org.apache.slide.util.TxLRUObjectCache
          org.apache.slide.util.ByteSizeLimitedObjectCache

public class ByteSizeLimitedObjectCache
extends TxLRUObjectCache

Transactional LRU byte counting object cache. Caches objects using a least-recently-used strategy. Asserts a given overall size of all cached objects does not exceed a specified limit. It provides basic isolation from other transactions and atomicity of all operations. As no locking is used (which is undesirable mainly as a cache should never block and a commit must never fail) serializability needs to be guaranteed by underlying stores. Note: Unlike `TxLRUObjectCache` this cache also limits the size of temporary caches inside transactions. This is necessary as size of bytes in a transaction can become really big. In case an entry can not be cached inisde a transaction it will be marked as invalid after commit of that tx.

Version:
  $Revision: 1.5 $
See Also:
  `TxLRUObjectCache`

Nested Class Summary
`protected class` | `ByteSizeLimitedObjectCache.SizeCountingLRUMap`

Field Summary
`protected long` | `globalByteSize`
`protected static int` | `MAX_FREEING_TRIES`
`protected long` | `maxByteSizePerEntry`
`protected long` | `txByteSize`
`protected int` | `txCacheSize`

Fields inherited from class org.apache.slide.util.TxLRUObjectCache
`globalCache, hits, logChannel, logger, loggingEnabled, misses, name, noGlobalCachingInsideTx, txChangeCaches, txDeleteCaches`

Constructor Summary
`ByteSizeLimitedObjectCache(int globalCacheSize, int txCacheSize, long globalByteSize, long txByteSize, long maxByteSizePerEntry, java.lang.String name, Logger logger, boolean noGlobalCachingInsideTx)` Creates a new object cache.

Method Summary
`boolean` | `canCache(java.lang.Object txId, long byteSize)`
`void` | `clear()`
`void` | `commit(java.lang.Object txId)`
`void` | `put(java.lang.Object txId, java.lang.Object key, java.lang.Object value, long byteSize)`
`void` | `start(java.lang.Object txId)`

Methods inherited from class org.apache.slide.util.TxLRUObjectCache
`deprune, forget, get, hit, log, miss, prune, put, remove, remove, rollback`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### MAX_FREEING_TRIES

    protected static final int MAX_FREEING_TRIES

See Also:
  Constant Field Values

### globalByteSize

    protected long globalByteSize

### txCacheSize

    protected int txCacheSize

### txByteSize

    protected long txByteSize

### maxByteSizePerEntry

    protected long maxByteSizePerEntry

Constructor Detail

### ByteSizeLimitedObjectCache

    public ByteSizeLimitedObjectCache(int globalCacheSize,
                                      int txCacheSize,
                                      long globalByteSize,
                                      long txByteSize,
                                      long maxByteSizePerEntry,
                                      java.lang.String name,
                                      Logger logger,
                                      boolean noGlobalCachingInsideTx)

  Creates a new object cache. The maximum cache size can be configured for local transaction caches as well as on a global level. The idea of having a maximum size in bytes per entry is to prevent a large entry to displace many small entries.

Parameters:
  `globalCacheSize` - maximum size in objects of global cache
  `txCacheSize` - maximum size in objects for local transaction cache
  `globalByteSize` - maximum size in bytes of global cache
  `txByteSize` - maximum size in bytes for local transaction cache
  `maxByteSizePerEntry` - maximum size of a single cache entry in bytes
  `name` - the name used to construct logging category / channel
  `logger` - Slide logger to be used for logging
  `noGlobalCachingInsideTx` - indicates global caches are enabled, but shall not be used inside transactions

Method Detail

### clear

    public void clear()

  Overrides:
    `clear` in class `TxLRUObjectCache`

### canCache

    public boolean canCache(java.lang.Object txId,
                            long byteSize)

### put

    public void put(java.lang.Object txId,
                    java.lang.Object key,
                    java.lang.Object value,
                    long byteSize)

### start

    public void start(java.lang.Object txId)

  Overrides:
    `start` in class `TxLRUObjectCache`

### commit

    public void commit(java.lang.Object txId)

  Overrides:
    `commit` in class `TxLRUObjectCache`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD