scalacache

package scalacache

Author: chris Created: 4/21/14

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. scalacache
  2. AnyRef
  3. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Type Members

  1. trait Cache extends AnyRef

  2. case class CacheConfig(keyPrefix: Option[String] = None, keySeparator: String = ":") extends Product with Serializable

    Configuration options for ScalaCache

    Configuration options for ScalaCache

    keyPrefix

    A global prefix that should be prepended to all cache keys. Useful for namespacing if you are sharing your cache with another application.

    keySeparator

    The value used to separate different parts of a cache key

  3. trait CacheKeyBuilder extends AnyRef

    Author: c-birchall Date: 2014/04/22

  4. trait LoggingSupport extends AnyRef

    Helper methods for logging

    Helper methods for logging

    Author: chris Created: 4/9/14

  5. case class ScalaCache(cache: Cache, cacheConfig: CacheConfig = CacheConfig(), keyBuilder: CacheKeyBuilder = DefaultCacheKeyBuilder, memoization: MemoizationConfig = MemoizationConfig()) extends Product with Serializable

    Container holding the cache itself, along with all necessary configuration.

    Container holding the cache itself, along with all necessary configuration.

    cache

    The cache itself

    memoization

    Configuration related to method memoization

Value Members

  1. object DefaultCacheKeyBuilder extends CacheKeyBuilder

  2. def caching[V](keyParts: Any*)(f: ⇒ V)(implicit scalaCache: ScalaCache): V

    Wrap the given block with a caching decorator.

    Wrap the given block with a caching decorator. First look in the cache. If the value is found, then return it immediately. Otherwise run the block and save the result in the cache before returning it.

    Note: Because no TTL is specified, the result will be stored in the cache indefinitely.

    V

    the type of the block's result

    keyParts

    data to be used to generate the cache key. This could be as simple as just a single String. See CacheKeyBuilder.

    f

    the block to run

    returns

    the result, either retrived from the cache or returned by the block

  3. def cachingWithTTL[V](keyParts: Any*)(ttl: Duration)(f: ⇒ V)(implicit scalaCache: ScalaCache): V

    Wrap the given block with a caching decorator.

    Wrap the given block with a caching decorator. First look in the cache. If the value is found, then return it immediately. Otherwise run the block and save the result in the cache before returning it.

    The result will be stored in the cache until the given TTL expires.

    V

    the type of the block's result

    keyParts

    data to be used to generate the cache key. This could be as simple as just a single String. See CacheKeyBuilder.

    ttl

    Time To Live

    f

    the block to run

    returns

    the result, either retrived from the cache or returned by the block

  4. def get[V](keyParts: Any*)(implicit scalaCache: ScalaCache): Future[Option[V]]

    Get the value corresponding to the given key from the cache.

    Get the value corresponding to the given key from the cache.

    Depending on the cache implementation, this may be done synchronously or asynchronously, so it returns a Future.

    V

    the type of the corresponding value

    keyParts

    data to be used to generate the cache key. This could be as simple as just a single String. See CacheKeyBuilder.

    returns

    the value, if there is one

  5. def getSync[V](keyParts: Any*)(implicit scalaCache: ScalaCache): Option[V]

    Convenience method to get a value from the cache synchronously.

    Convenience method to get a value from the cache synchronously. Warning: may block indefinitely!

    V

    the type of the corresponding value

    keyParts

    data to be used to generate the cache key. This could be as simple as just a single String. See CacheKeyBuilder.

    returns

    the value, if there is one

  6. package memoization

    Utilities for memoizing the results of method calls in a cache.

    Utilities for memoizing the results of method calls in a cache. The cache key is generated from the method arguments using a macro, so that you don't have to bother passing them manually.

  7. def put[V](keyParts: Any*)(value: V, ttl: Option[Duration] = None)(implicit scalaCache: ScalaCache): Future[Unit]

    Insert the given key-value pair into the cache, with an optional Time To Live.

    Insert the given key-value pair into the cache, with an optional Time To Live.

    Depending on the cache implementation, this may be done synchronously or asynchronously, so it returns a Future.

    V

    the type of the corresponding value

    keyParts

    data to be used to generate the cache key. This could be as simple as just a single String. See CacheKeyBuilder.

    value

    the value to be cached

    ttl

    Time To Live (optional, if not specified then the entry will be cached indefinitely)

  8. def remove(keyParts: Any*)(implicit scalaCache: ScalaCache): Future[Unit]

    Remove the given key and its associated value from the cache, if it exists.

    Remove the given key and its associated value from the cache, if it exists. If the key is not in the cache, do nothing.

    Depending on the cache implementation, this may be done synchronously or asynchronously, so it returns a Future.

    keyParts

    data to be used to generate the cache key. This could be as simple as just a single String. See CacheKeyBuilder.

Inherited from AnyRef

Inherited from Any

Ungrouped