Created
October 18, 2015 13:31
-
-
Save missingfaktor/4048f7f12b87313fb05c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| trait Cache[R[_], W[_], Eff[_]] { | |
| def save[V](key: String, value: V)(implicit writes: W[V]): Eff[Unit] | |
| def retrieve[V](key: String)(implicit reads: R[V]): Eff[Option[V]] | |
| } | |
| // In-memory cache. Potentially backed by a Map[String, Any]. | |
| // Needs no reads or writes. | |
| class InMemoryCache extends Cache[Tautology1, Tautology1, Id] { | |
| def save[V](key: String, value: V)(implicit writes: Tautology1[V]): Unit = ??? | |
| def retrieve[V](key: String)(implicit reads: Tautology1[V]): Option[V] = ??? | |
| } | |
| class Tautology1[+A] private() | |
| object Tautology { | |
| implicit val tautology1 = new Tautology[Nothing] | |
| } | |
| // Zookeeper-based cache | |
| class ZkCache extends Cache[ZkReads, ZkWrites, Future] { | |
| def save[V](key: String, value: V)(implicit writes: ZkWrites[V]): Future[Unit] = ??? | |
| def retrieve[V](key: String)(implicit reads: ZkReads[V]): Future[Option[V]] = ??? | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment