scala-cache


License

License

Categories

Categories

Scala Languages
GroupId

GroupId

io.github.ctiliescu
ArtifactId

ArtifactId

scala-cache_2.12
Last Version

Last Version

0.1
Release Date

Release Date

Type

Type

jar
Description

Description

scala-cache
scala-cache
Project URL

Project URL

https://github.com/ctiliescu/scala-cache
Project Organization

Project Organization

io.github.ctiliescu
Source Code Management

Source Code Management

https://github.com/ctiliescu/scala-cache

Download scala-cache_2.12

How to add to project

<!-- https://jarcasting.com/artifacts/io.github.ctiliescu/scala-cache_2.12/ -->
<dependency>
    <groupId>io.github.ctiliescu</groupId>
    <artifactId>scala-cache_2.12</artifactId>
    <version>0.1</version>
</dependency>
// https://jarcasting.com/artifacts/io.github.ctiliescu/scala-cache_2.12/
implementation 'io.github.ctiliescu:scala-cache_2.12:0.1'
// https://jarcasting.com/artifacts/io.github.ctiliescu/scala-cache_2.12/
implementation ("io.github.ctiliescu:scala-cache_2.12:0.1")
'io.github.ctiliescu:scala-cache_2.12:jar:0.1'
<dependency org="io.github.ctiliescu" name="scala-cache_2.12" rev="0.1">
  <artifact name="scala-cache_2.12" type="jar" />
</dependency>
@Grapes(
@Grab(group='io.github.ctiliescu', module='scala-cache_2.12', version='0.1')
)
libraryDependencies += "io.github.ctiliescu" % "scala-cache_2.12" % "0.1"
[io.github.ctiliescu/scala-cache_2.12 "0.1"]

Dependencies

compile (5)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.12.8
io.circe : circe-core_2.12 jar 0.11.0
io.circe : circe-generic_2.12 jar 0.11.0
io.circe : circe-parser_2.12 jar 0.11.0
net.debasishg : redisclient_2.12 jar 3.9

Project Modules

There are no modules declared in this project.

Scala cache library using Redis

Key features of the library


Instalation


The artifacts are published to Maven Central.

libraryDependencies ++= Seq(
  "io.github.ctiliescu" % "scala-cache_2.12" % "0.1",
  ...
)

Usage


To be able to cache the function results, the CacheCompuser should be mixed and defined the RedisConfig properties(address and port).

class Test extends CacheComposer {
  override val conf = RedisConfig("localhost", 6379)

  def func(arg1: String, arg2: String): String = {
    println("Start execute complex function")
    // Very time consuming function
    s"$arg1:$arg2"
  };

  var r1 = cache(func, "v1", "v2")
  pritnln(r1)
  var r2 = cache(func, "v1", "v2")
  pritnln(r2)
  var r3 = cache(func, "v1", "v3")
  pritnln(r3)
  var r4 = cache(func, "v1", "v2")
  pritnln(r4)
}

When the Test class is executed the output will be:

  scala> "execute_test_class"
  Start execute complex function
  v1:v2
  v1:v2
  Start execute complex function
  v1:v3
  v1:v2

Requirements


Versions

Version
0.1