ru.dimgel.lib.cache

MapCache

class MapCache [K, V] extends Cache

Caches objects of type V by some key K. All methods are thread-safe. "Negative result" semantics is not supported; if you want it, use V=Option[V'].

Useful for caching entities by their IDs, for example.

Linear Supertypes
Cache, AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Hide All
  2. Show all
  1. MapCache
  2. Cache
  3. AnyRef
  4. Any
Visibility
  1. Public
  2. All

Instance Constructors

  1. new MapCache (enabled: ⇒ Boolean, maxElements_?: ⇒ Option[Int])

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 (key: K, valueProvider: (K) ⇒ V): V

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

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

    • if cache already contains some value bound to given key, that value is returned;
    • otherwise second argument value is queried, stored into cache under given key and returned.

    In both cases old/new cache entry is placed to the head of "recently accessed" list.

    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
    MapCacheCache
  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
    MapCacheCache
  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, Option[Int])

    Attributes
    protected final
    Definition Classes
    MapCacheCache
  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
    MapCacheCache
  25. def remove (key: K): Unit

    Invalidates single cache entry.

    Invalidates single cache entry.

    Attributes
    final
  26. def set (data: Map[K, V]): Unit

    Reloads whole cache data.

    Reloads whole cache data.

    Made public because maybe useful for optimizations. Use with caution.

    Implementation just invalidates whole cache and then calls set(key, value) for each provided data entry. So, if data size is greater than maxElements, elements iterated first will be evicted.

    Attributes
    final
  27. def set (key: K, value: V): Unit

    Stores provided value into cache under given key.

    Stores provided value into cache under given key. Used internally by apply().

    Made public because maybe useful for optimizations. For example, when cached entity is updated into entriesByKeybase, setting cache value instead of clearing cache would eliminate additional call to SQL SELECT. Use with caution.

    If cache already contains maxElements elements but does not already contain specified key (i.e. requested operation is "insert", not "update"), the last entry from "recently accessed" list will be evicted. The new/updated entry is placed at the top of "recently accessed" entries list.

    Attributes
    final
  28. var stat_numClears : Long

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

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

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

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

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

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

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

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

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

    Attributes
    final
    Definition Classes
    AnyRef
    Annotations
    @throws()

Inherited from Cache

Inherited from AnyRef

Inherited from Any