| 56 | * @category models |
| 57 | */ |
| 58 | export interface Cache<in out Key, in out Value, out Error = never> |
| 59 | extends ConsumerCache<Key, Value, Error>, Cache.Variance<Key, Value, Error> |
| 60 | { |
| 61 | /** |
| 62 | * Retrieves the value associated with the specified key if it exists. |
| 63 | * Otherwise computes the value with the lookup function, puts it in the |
| 64 | * cache, and returns it. |
| 65 | */ |
| 66 | get(key: Key): Effect.Effect<Value, Error> |
| 67 | |
| 68 | /** |
| 69 | * Retrieves the value associated with the specified key if it exists as a left. |
| 70 | * Otherwise computes the value with the lookup function, puts it in the |
| 71 | * cache, and returns it as a right. |
| 72 | */ |
| 73 | getEither(key: Key): Effect.Effect<Either<Value, Value>, Error> |
| 74 | |
| 75 | /** |
| 76 | * Computes the value associated with the specified key, with the lookup |
| 77 | * function, and puts it in the cache. The difference between this and |
| 78 | * `get` method is that `refresh` triggers (re)computation of the value |
| 79 | * without invalidating it in the cache, so any request to the associated |
| 80 | * key can still be served while the value is being re-computed/retrieved |
| 81 | * by the lookup function. Additionally, `refresh` always triggers the |
| 82 | * lookup function, disregarding the last `Error`. |
| 83 | */ |
| 84 | refresh(key: Key): Effect.Effect<void, Error> |
| 85 | |
| 86 | /** |
| 87 | * Associates the specified value with the specified key in the cache. |
| 88 | */ |
| 89 | set(key: Key, value: Value): Effect.Effect<void> |
| 90 | } |
| 91 | |
| 92 | /** |
| 93 | * A ConsumerCache models a portion of a cache which is safe to share without allowing to create new values or access existing ones. |
no outgoing calls
no test coverage detected