mkotsur / artc   0.1.3

MIT License GitHub

Active Read Through Cache

Scala versions: 2.13

Artc Build Status Maven Central Known Vulnerabilities Cats friendly

Artc (pronounced art·sy) is an Active Read-Through Cache for cats-effect programs. Its primary goal is to allow developers to write as little code as possible to solve a common problem of reading data from services with high latency.

Motivation

Sometimes you need to integrate with slow services. This is rarely a pleasant problem to solve, but it doesn't have to take weeks to solve and destroy your development experience. Artc is here to help!

Main features

  • Non-blocking read-through;
  • Active content synchronization;
  • Automatic refresh rate adjustment;
  • Use it as a library or a REST microservice (soon).

How Artc works

Example

import io.github.mkotsur.artc.Cache
import cats.effect.{ExitCode, IO, IOApp}

// 1. Configure
case class User(name: String)

val settings: Cache.Settings  = ???
val readSource: IO[List[User]] = ???

// 2. Create as resource
val cacheR: Resource[IO, Cache[List[User]]] = 
  Cache.create(settings, readSource)

// 3. Use
for {
  latest <- cacheR.use(cache => cache.latest)
  _ <- IO(println(v))   
  _ <- updateSharesFiber.join
} yield ExitCode.Success

Adding to your project

Scala versions supported: 2.13.x.

libraryDependencies += "io.github.mkotsur" %% "artc" % {latest-version}