Packages

p

scalacache

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

    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]
  3. class AsyncForFuture extends Async[Future]
  4. trait Cache[V] extends CacheAlg[V]
  5. trait CacheAlg[V] extends AnyRef

    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
  7. trait CacheKeyBuilder extends AnyRef
  8. case class DefaultCacheKeyBuilder(keyPrefix: Option[String] = None, separator: String = ":") extends CacheKeyBuilder with Product with Serializable
  9. case class Entry[+A](value: A, expiresAt: Option[Instant]) extends Product with Serializable

    A cache entry with an optional expiry time

  10. 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

  11. 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

  12. type Id[X] = X
  13. trait LoggingSupport extends AnyRef

    Helper methods for logging

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

    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
  16. final class RemoveAll[V] extends AnyRef
  17. trait Sync[F[_]] extends MonadError[F]

Value Members

  1. def caching[F[_], V](keyParts: Any*)(ttl: Option[Duration])(f: ⇒ V)(implicit cache: Cache[V], mode: Mode[F], flags: Flags): F[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.

    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

  2. def cachingF[F[_], V](keyParts: Any*)(ttl: Option[Duration])(f: ⇒ F[V])(implicit cache: Cache[V], mode: Mode[F], flags: Flags): F[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.

    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

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

    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

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

    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

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

    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

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

    Remove all values from the cache.

    Remove all values from the cache.

    V

    The type of values to be removed

  7. object AsyncForId extends Async[Id]
  8. object AsyncForTry extends Async[Try]
  9. object CacheConfig extends Serializable
  10. object Flags extends Serializable
  11. object MD5 extends HashingAlgorithm with Product with Serializable

    MD5 returns 32 character long hexadecimal hash strings

  12. object SHA1 extends HashingAlgorithm with Product with Serializable

    SHA1 returns 40 character long hexadecimal hash strings

  13. object SHA256 extends HashingAlgorithm with Product with Serializable

    SHA256 returns 64 character long hexadecimal hash strings

  14. object SHA512 extends HashingAlgorithm with Product with Serializable

    SHA512 returns 128 character long hexadecimal hash strings

  15. object modes
  16. object sync

    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