Package

scalacache

Permalink

package scalacache

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

Type Members

  1. trait AbstractCache[V] extends Cache[V] with LoggingSupport

    Permalink

    An abstract implementation of CacheAlg that takes care of some things that are common across all concrete implementations.

    An abstract implementation of CacheAlg that takes care of some things that are common across all concrete implementations.

    If you are writing a cache implementation, you probably want to extend this trait rather than extending CacheAlg directly.

    V

    The value of types stored in the cache.

  2. trait Async[F[_]] extends Sync[F]

    Permalink
  3. class AsyncForFuture extends Async[Future]

    Permalink
  4. trait Cache[V] extends CacheAlg[V]

    Permalink
  5. trait CacheAlg[V] extends AnyRef

    Permalink

    Abstract algebra describing the operations a cache can perform

    Abstract algebra describing the operations a cache can perform

    V

    The value of types stored in the cache.

  6. case class CacheConfig(cacheKeyBuilder: CacheKeyBuilder = DefaultCacheKeyBuilder(), memoization: MemoizationConfig = MemoizationConfig()) extends Product with Serializable

    Permalink
  7. trait CacheKeyBuilder extends AnyRef

    Permalink
  8. case class DefaultCacheKeyBuilder(keyPrefix: Option[String] = None, separator: String = ":") extends CacheKeyBuilder with Product with Serializable

    Permalink
  9. case class Entry[+A](value: A, expiresAt: Option[Instant]) extends Product with Serializable

    Permalink

    A cache entry with an optional expiry time

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

    Permalink

    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

  11. sealed trait HashingAlgorithm extends AnyRef

    Permalink

    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

  12. type Id[X] = X

    Permalink
  13. trait LoggingSupport extends AnyRef

    Permalink

    Helper methods for logging

  14. trait Mode[F[_]] extends AnyRef

    Permalink

    When using ScalaCache you must import a mode in order to specify the effect monad in which you want to wrap your computations.

    When using ScalaCache you must import a mode in order to specify the effect monad in which you want to wrap your computations.

    F

    The effect monad that will wrap the return value of any cache operations. e.g. scalacache.Id, scala.concurrent.Future, scala.util.Try or cats-effect IO.

    Annotations
    @implicitNotFound( ... )
  15. trait MonadError[F[_]] extends AnyRef

    Permalink
  16. final class RemoveAll[V] extends AnyRef

    Permalink
  17. trait Sync[F[_]] extends MonadError[F]

    Permalink

Value Members

  1. object AsyncForId extends Async[Id]

    Permalink
  2. object AsyncForTry extends Async[Try]

    Permalink
  3. object CacheConfig extends Serializable

    Permalink
  4. object Flags extends Serializable

    Permalink
  5. object MD5 extends HashingAlgorithm with Product with Serializable

    Permalink

    MD5 returns 32 character long hexadecimal hash strings

  6. object SHA1 extends HashingAlgorithm with Product with Serializable

    Permalink

    SHA1 returns 40 character long hexadecimal hash strings

  7. object SHA256 extends HashingAlgorithm with Product with Serializable

    Permalink

    SHA256 returns 64 character long hexadecimal hash strings

  8. object SHA512 extends HashingAlgorithm with Product with Serializable

    Permalink

    SHA512 returns 128 character long hexadecimal hash strings

  9. def caching[F[_], V](keyParts: Any*)(ttl: Option[Duration])(f: ⇒ V)(implicit cache: Cache[V], mode: Mode[F], flags: Flags): F[V]

    Permalink

    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.

    F

    The type of container in which the result will be wrapped. This is decided by the mode.

    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

    The time-to-live to use when inserting into the cache. If specified, the cache entry will expire after this time has elapsed.

    f

    The block to run

    cache

    The cache

    mode

    The operation mode, which decides the type of container in which to wrap the result

    flags

    Flags used to conditionally alter the behaviour of ScalaCache

    returns

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

  10. def cachingF[F[_], V](keyParts: Any*)(ttl: Option[Duration])(f: ⇒ F[V])(implicit cache: Cache[V], mode: Mode[F], flags: Flags): F[V]

    Permalink

    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.

    F

    The type of container in which the result will be wrapped. This is decided by the mode.

    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

    The time-to-live to use when inserting into the cache. If specified, the cache entry will expire after this time has elapsed.

    f

    The block to run

    cache

    The cache

    mode

    The operation mode, which decides the type of container in which to wrap the result

    flags

    Flags used to conditionally alter the behaviour of ScalaCache

    returns

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

  11. def get[F[_], V](keyParts: Any*)(implicit cache: Cache[V], mode: Mode[F], flags: Flags): F[Option[V]]

    Permalink

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

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

    F

    The type of container in which the result will be wrapped. This is decided by the mode.

    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.

    cache

    The cache

    mode

    The operation mode, which decides the type of container in which to wrap the result

    flags

    Flags used to conditionally alter the behaviour of ScalaCache

    returns

    the value, if there is one

  12. package memoization

    Permalink

    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.

  13. object modes

    Permalink
  14. def put[F[_], V](keyParts: Any*)(value: V, ttl: Option[Duration] = None)(implicit cache: Cache[V], mode: Mode[F], flags: Flags): F[Any]

    Permalink

    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.

    F

    The type of container in which the result will be wrapped. This is decided by the mode.

    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)

    cache

    The cache

    mode

    The operation mode, which decides the type of container in which to wrap the result

    flags

    Flags used to conditionally alter the behaviour of ScalaCache

  15. def remove[F[_], V](keyParts: Any*)(implicit cache: Cache[V], mode: Mode[F]): F[Any]

    Permalink

    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.

    F

    The type of container in which the result will be wrapped. This is decided by the mode.

    V

    The type of the value to be removed

    keyParts

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

    cache

    The cache

    mode

    The operation mode, which decides the type of container in which to wrap the result

  16. def removeAll[V]: RemoveAll[V]

    Permalink

    Remove all values from the cache.

    Remove all values from the cache.

    V

    The type of values to be removed

  17. package serialization

    Permalink
  18. object sync

    Permalink

    A version of the API that is specialised to Id.

    A version of the API that is specialised to Id. The functions in this API perform their operations immediately on the current thread and thus do not wrap their results in any effect monad.

    Implementation note: I really didn't want to have this separate copy of the API, but I couldn't get type inference to understand that Id[A] == A. e.g. the following doesn't compile:

    implicit val cache: LovelyCache[String] = ??? import scalacache.modes.sync._ val x: Option[String] = scalacache.get("hello")

    [error] ... polymorphic expression cannot be instantiated to expected type; [error] found : [F[_], V]F[Option[V]] [error] required: Option[String]

    If anyone can find a workaround to make this compile, I will be much obliged.

Inherited from AnyRef

Inherited from Any

Ungrouped