Overview | Package | Class | Deprecated | Index | Help
| Groovy Documentation
| FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.codehaus.groovy.grails.web.util
[Java] Class CacheEntry

    java.lang.Object
      org.codehaus.groovy.grails.web.util.CacheEntry

    public class CacheEntry
    extends java.lang.Object

Wrapper for a value inside a cache that adds timestamp information for expiration and prevents "cache storms" with a Lock. JMM happens-before is ensured with AtomicReference. Objects in cache are assumed to not change after publication.

Authors:
  Lari Hotari

Field Summary
`protected long` | `createdMillis`
`protected java.util.concurrent.atomic.AtomicReference` | `valueRef`
`protected java.util.concurrent.locks.Lock` | `writeLock`

Constructor Summary
`CacheEntry(java.lang.Object value)`

Method Summary
`void` | `expire()`
`long` | `getCreatedMillis()`
`java.lang.Object` | `getValue(long timeout, java.security.PrivilegedAction updater)` gets the current value from the entry and updates it if it's older than timeout
`java.lang.Object` | `getValue()`
`protected boolean` | `hasExpired(long timeout)`
`protected void` | `resetTimestamp()`
`protected boolean` | `shouldUpdate(long beforeLockingCreatedMillis)`

Methods inherited from class java.lang.Object
java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()

Field Detail

### createdMillis

    protected long createdMillis

### valueRef

    protected java.util.concurrent.atomic.AtomicReference valueRef

### writeLock

    protected java.util.concurrent.locks.Lock writeLock

Constructor Detail

### CacheEntry

    public CacheEntry(java.lang.Object value)

Method Detail

### expire

    public void expire()

### getCreatedMillis

    public long getCreatedMillis()

### getValue

    public java.lang.Object getValue(long timeout, java.security.PrivilegedAction updater)

  gets the current value from the entry and updates it if it's older than timeout updater is a callback for creating an updated value.
  Parameters:
    timeout
    updater
  Returns:
    The atomic reference

### getValue

    public java.lang.Object getValue()

### hasExpired

    protected boolean hasExpired(long timeout)

### resetTimestamp

    protected void resetTimestamp()

### shouldUpdate

    protected boolean shouldUpdate(long beforeLockingCreatedMillis)

Groovy Documentation