Packages

p

scalacache

package scalacache

Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. scalacache
  2. JavaSerializationCodec
  3. AnyRef
  4. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. trait Cache [Repr] extends AnyRef
  2. case class CacheConfig (keyPrefix: Option[String] = None, keySeparator: String = ":", waitForWriteToComplete: Boolean = true) 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

    waitForWriteToComplete

    If true, the Future returned by caching (or memoize) will not complete until the cache write has completed. If false, the Future will complete as soon as the value has been computed, and the cache write will happen asynchronously. The latter was the behaviour until ScalaCache 0.9.2, but the former is more useful in many situations.

  3. trait CacheKeyBuilder extends AnyRef
  4. case class Entry [+A](value: A, expiresAt: Option[DateTime]) extends Product with Serializable

    A cache entry with an optional expiry time

  5. case class Flags (readsEnabled: Boolean = true, writesEnabled: Boolean = true) extends Product with Serializable

    Configuration flags for conditionally altering the behaviour of ScalaCache.

    Configuration flags for conditionally altering the behaviour of ScalaCache.

    readsEnabled

    if false, cache GETs will be skipped (and will return None)

    writesEnabled

    if false, cache PUTs will be skipped

  6. sealed trait HashingAlgorithm extends AnyRef

    Sealed HashingAlgorithm trait to prevent users from shooting themselves in the foot at runtime by specifying a crappy/unsupported algorithm name

    Sealed HashingAlgorithm trait to prevent users from shooting themselves in the foot at runtime by specifying a crappy/unsupported algorithm name

    The name should be a valid MessageDigest algorithm name.Implementing child classes/objects should refer to this list for proper names:

    http://docs.oracle.com/javase/6/docs/technotes/guides/security/StandardNames.html#MessageDigest

  7. trait LoggingSupport extends AnyRef

    Helper methods for logging

  8. type NoSerialization = InMemoryRepr
  9. case class ScalaCache [Repr](cache: Cache[Repr], 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

  10. class TypedApi [From, Repr] extends AnyRef

Value Members

  1. implicit def AnyRefBinaryCodec[S <: Serializable](implicit ev: ClassTag[S]): Codec[S, Array[Byte]]

    Uses plain Java serialization to deserialize objects

    Uses plain Java serialization to deserialize objects

    Definition Classes
    JavaSerializationCodec
  2. def caching[V, Repr](keyParts: Any*)(f: ⇒ Future[V])(implicit scalaCache: ScalaCache[Repr], flags: Flags, execContext: ExecutionContext = ExecutionContext.global, codec: Codec[V, Repr]): Future[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.

    All of the above happens asynchronously, so a Future is returned immediately. Specifically: - when the cache lookup completes, if it is a miss, the block execution is started. - at some point after the block execution completes, the result is written asynchronously to the cache. - the Future returned from this method does not wait for the cache write before completing.

    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 cachingForMemoize[V, Repr](key: String)(optionalTtl: Option[Duration])(f: ⇒ Future[V])(implicit scalaCache: ScalaCache[Repr], flags: Flags, execContext: ExecutionContext = ExecutionContext.global, codec: Codec[V, Repr]): Future[V]
  4. def cachingWithOptionalTTL[V, Repr](keyParts: Any*)(optionalTtl: Option[Duration])(f: ⇒ Future[V])(implicit scalaCache: ScalaCache[Repr], flags: Flags, execContext: ExecutionContext = ExecutionContext.global, codec: Codec[V, Repr]): Future[V]
  5. def cachingWithTTL[V, Repr](keyParts: Any*)(ttl: Duration)(f: ⇒ Future[V])(implicit scalaCache: ScalaCache[Repr], flags: Flags, execContext: ExecutionContext = ExecutionContext.global, codec: Codec[V, Repr]): Future[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.

    All of the above happens asynchronously, so a Future is returned immediately. Specifically: - when the cache lookup completes, if it is a miss, the block execution is started. - at some point after the block execution completes, the result is written asynchronously to the cache. - the Future returned from this method does not wait for the cache write before completing.

    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

  6. def get[V, Repr](keyParts: Any*)(implicit scalaCache: ScalaCache[Repr], flags: Flags, codec: Codec[V, Repr]): 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

  7. def put[V, Repr](keyParts: Any*)(value: V, ttl: Option[Duration] = None)(implicit scalaCache: ScalaCache[Repr], flags: Flags, codec: Codec[V, Repr]): 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.

  9. def removeAll()(implicit scalaCache: ScalaCache[_]): Future[Unit]

    Delete the entire contents of the cache.

    Delete the entire contents of the cache. Use wisely!

  10. def typed[V, Repr](implicit scalaCache: ScalaCache[Repr], codec: Codec[V, Repr]): TypedApi[V, Repr]

    Create an instance of the 'typed' API that limits use of the cache to a single type.

    Create an instance of the 'typed' API that limits use of the cache to a single type.

    This means you can't accidentally put something of the wrong type into your cache, and it reduces keystrokes because you don't need to specify types when calling get, put, etc.

    e.g.

    import scalacache._
    implicit val sc: ScalaCache = ...
    
    val intCache = typed[Int]
    
    intCache.put("one")(1) // OK
    intCache.put("two")(2.0) // Nope! Compiler error
    
    val one = intCache.get("1") // returns a Future[Option[Int]]
    V

    the type of values that the cache will accept

  11. object DefaultCacheKeyBuilder extends CacheKeyBuilder
  12. object Flags extends Serializable
  13. object MD5 extends HashingAlgorithm with Product with Serializable

    MD5 returns 32 character long hexadecimal hash strings

  14. object SHA1 extends HashingAlgorithm with Product with Serializable

    SHA1 returns 40 character long hexadecimal hash strings

  15. object SHA256 extends HashingAlgorithm with Product with Serializable

    SHA256 returns 64 character long hexadecimal hash strings

  16. object SHA512 extends HashingAlgorithm with Product with Serializable

    SHA512 returns 128 character long hexadecimal hash strings

  17. object sync

    Synchronous API, for the case when you don't want to deal with Futures.

Deprecated Value Members

  1. def getSync[V, Repr](keyParts: Any*)(implicit scalaCache: ScalaCache[Repr], flags: Flags, codec: Codec[V, Repr]): 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

    Annotations
    @deprecated
    Deprecated

    (Since version 0.7.0) This method has moved. Please use scalacache.sync.get

Inherited from JavaSerializationCodec

Inherited from AnyRef

Inherited from Any

Ungrouped