Skip to content

Instantly share code, notes, and snippets.

@machuz
Created July 31, 2018 05:35
Show Gist options
  • Save machuz/b3e316d81cdf63d927fd15c2b7304856 to your computer and use it in GitHub Desktop.
Save machuz/b3e316d81cdf63d927fd15c2b7304856 to your computer and use it in GitHub Desktop.
CacheIOのADT
sealed abstract class CacheIO[+A] {}
object CacheIO extends CacheIOCreation {
case class Put[T](
key: CacheKey,
value: T,
expireSecond: Option[Long],
fmt: ByteStringFormatter[T]
) extends CacheIO[T]
case class PutList[T](
key: CacheKey,
values: Seq[T],
expireSecond: Option[Long],
fmt: ByteStringFormatter[T]
) extends CacheIO[T]
case class Get[T](
key: CacheKey,
fmt: ByteStringFormatter[T]
) extends CacheIO[Option[T]]
case class GetList[T](
key: CacheKey,
fmt: ByteStringFormatter[T]
) extends CacheIO[Seq[T]]
case class Scan[T](
matchGlob: Option[CacheKeyGlob],
fmt: ByteStringFormatter[T]
) extends CacheIO[Seq[T]]
case class ScanOne[T](
matchGlob: CacheKeyGlob,
fmt: ByteStringFormatter[T]
) extends CacheIO[Option[T]]
case class Delete(
key: CacheKey
) extends CacheIO[Unit]
case class Has(
key: CacheKey
) extends CacheIO[Boolean]
case object Clear extends CacheIO[Unit]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment