ru.dimgel.lib.cache

ValueCache

class ValueCache [V] extends Cache

Caches a single value of type V. All methods are thread-safe. Negative results are not cached; if you want it, use V=Option[V'].

Usage example

Below T is Squeryl schema and Article is entity.

package dal
object Articles {
    private val listCache = new ValueCache[List[Article]]

    def list =
        listCache(from(T.article)(a => select(a) orderBy(a.whenCreated)))

    def add(a: Article) {
        T.article.insert(a)
        listCache.invalidate()
    }
    // ...
}
Linear Supertypes
Cache, AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Hide All
  2. Show all
  1. ValueCache
  2. Cache
  3. AnyRef
  4. Any
Visibility
  1. Public
  2. All

Instance Constructors

  1. new ValueCache (enabled: ⇒ Boolean)

Value Members

  1. def != (arg0: AnyRef): Boolean

    Attributes
    final
    Definition Classes
    AnyRef
  2. def != (arg0: Any): Boolean

    Attributes
    final
    Definition Classes
    Any
  3. def ## (): Int

    Attributes
    final
    Definition Classes
    AnyRef → Any
  4. def == (arg0: AnyRef): Boolean

    Attributes
    final
    Definition Classes
    AnyRef
  5. def == (arg0: Any): Boolean

    Attributes
    final
    Definition Classes
    Any
  6. def apply (valueProvider: ⇒ V): V

    This method acts like caching proxy for its by-name (calculated on demand) argument:

    This method acts like caching proxy for its by-name (calculated on demand) argument:

    • if cache already contains some value, that value is returned;
    • otherwise argument value is queried, stored into cache and returned.
    Attributes
    final
  7. def asInstanceOf [T0] : T0

    Attributes
    final
    Definition Classes
    Any
  8. def clear (): Unit

    Remove all cached data.

    Remove all cached data.

    Attributes
    final
    Definition Classes
    ValueCacheCache
  9. def clearStatistics (): Unit

    Attributes
    final
    Definition Classes
    Cache
  10. def clone (): AnyRef

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  11. val description : String

    Attributes
    protected
    Definition Classes
    ValueCacheCache
  12. def eq (arg0: AnyRef): Boolean

    Attributes
    final
    Definition Classes
    AnyRef
  13. def equals (arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  14. def finalize (): Unit

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  15. def getClass (): java.lang.Class[_]

    Attributes
    final
    Definition Classes
    AnyRef → Any
  16. def getStatistics (): CacheStatistics

    Attributes
    final
    Definition Classes
    Cache
  17. def getStatistics_aux (): (Boolean, Int, Some[Int])

    Attributes
    protected final
    Definition Classes
    ValueCacheCache
  18. def hashCode (): Int

    Definition Classes
    AnyRef → Any
  19. def init (): Unit

    Attributes
    protected final
    Definition Classes
    Cache
  20. def isInstanceOf [T0] : Boolean

    Attributes
    final
    Definition Classes
    Any
  21. def ne (arg0: AnyRef): Boolean

    Attributes
    final
    Definition Classes
    AnyRef
  22. def notify (): Unit

    Attributes
    final
    Definition Classes
    AnyRef
  23. def notifyAll (): Unit

    Attributes
    final
    Definition Classes
    AnyRef
  24. def reloadConfig (): Unit

    Attributes
    final
    Definition Classes
    ValueCacheCache
  25. def set (value: V): Unit

    Enforces cache to store provided value.

    Enforces cache to store provided value. Use with caution.

    This feature maybe useful for optimizations. For example, when cached entity is updated into database, setting cache value instead of clearing cache would eliminate additional call to SQL SELECT.

    Attributes
    final
  26. var stat_numClears : Long

    Attributes
    protected final
    Definition Classes
    Cache
  27. var stat_numHits : Long

    Attributes
    protected final
    Definition Classes
    Cache
  28. var stat_numMisses : Long

    Attributes
    protected final
    Definition Classes
    Cache
  29. var stat_numMissesBecauseDisabled : Long

    Attributes
    protected final
    Definition Classes
    Cache
  30. var stat_since : Date

    Attributes
    protected final
    Definition Classes
    Cache
  31. def synchronized [T0] (arg0: ⇒ T0): T0

    Attributes
    final
    Definition Classes
    AnyRef
  32. def toString (): String

    Definition Classes
    AnyRef → Any
  33. def wait (): Unit

    Attributes
    final
    Definition Classes
    AnyRef
    Annotations
    @throws()
  34. def wait (arg0: Long, arg1: Int): Unit

    Attributes
    final
    Definition Classes
    AnyRef
    Annotations
    @throws()
  35. def wait (arg0: Long): Unit

    Attributes
    final
    Definition Classes
    AnyRef
    Annotations
    @throws()

Inherited from Cache

Inherited from AnyRef

Inherited from Any