scalacache
package scalacache
- Alphabetic
- By Inheritance
- scalacache
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Package Members
- package logging
- 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.
- package serialization
Type Members
- trait AbstractCache[F[_], V] extends Cache[F, V] with LoggingSupport[F]
An abstract implementation of CacheAlg that takes care of some things that are common across all concrete implementations.
- trait Cache[F[_], V] extends CacheAlg[F, V]
- trait CacheAlg[F[_], V] extends AnyRef
Abstract algebra describing the operations a cache can perform
Abstract algebra describing the operations a cache can perform
- F
The effect monad in which all cache operations will be performed.
- V
The value of types stored in the cache.
- case class CacheConfig(cacheKeyBuilder: CacheKeyBuilder = DefaultCacheKeyBuilder(), memoization: MemoizationConfig = MemoizationConfig()) extends Product with Serializable
- trait CacheKeyBuilder extends AnyRef
- case class DefaultCacheKeyBuilder(keyPrefix: Option[String] = None, separator: String = ":") extends CacheKeyBuilder with Product with Serializable
- case class Entry[+A](value: A, expiresAt: Option[Instant]) extends Product with Serializable
A cache entry with an optional expiry time
- 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
- 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
- trait LoggingSupport[F[_]] extends AnyRef
Helper methods for logging
- final class RemoveAll[V] extends AnyRef
Value Members
- def caching[F[_], V](keyParts: Any*)(ttl: Option[Duration])(f: => V)(implicit cache: Cache[F, V], 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: If ttl is set to None, 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
- flags
Flags used to conditionally alter the behaviour of ScalaCache
- returns
The result, either retrived from the cache or returned by the block
- def cachingF[F[_], V](keyParts: Any*)(ttl: Option[Duration])(f: => F[V])(implicit cache: Cache[F, V], 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: If ttl is set to None, 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
- flags
Flags used to conditionally alter the behaviour of ScalaCache
- returns
The result, either retrived from the cache or returned by the block
- def get[F[_], V](keyParts: Any*)(implicit cache: Cache[F, V], 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
- flags
Flags used to conditionally alter the behaviour of ScalaCache
- returns
the value, if there is one
- def put[F[_], V](keyParts: Any*)(value: V, ttl: Option[Duration] = None)(implicit cache: Cache[F, V], flags: Flags): F[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.
- 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
- flags
Flags used to conditionally alter the behaviour of ScalaCache
- def remove[F[_], V](keyParts: Any*)(implicit cache: Cache[F, V]): F[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.
- 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
- 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
- object CacheConfig extends Serializable
- object Entry extends Serializable
- object Flags extends Serializable
- object MD5 extends HashingAlgorithm with Product with Serializable
MD5 returns 32 character long hexadecimal hash strings
- object SHA1 extends HashingAlgorithm with Product with Serializable
SHA1 returns 40 character long hexadecimal hash strings
- object SHA256 extends HashingAlgorithm with Product with Serializable
SHA256 returns 64 character long hexadecimal hash strings
- object SHA512 extends HashingAlgorithm with Product with Serializable
SHA512 returns 128 character long hexadecimal hash strings