redis-algebra


License

License

MIT
Categories

Categories

Redis Data Databases
GroupId

GroupId

com.github.ethul
ArtifactId

ArtifactId

redis-algebra_2.10
Last Version

Last Version

0.1.3
Release Date

Release Date

Type

Type

jar
Description

Description

redis-algebra
redis-algebra
Project URL

Project URL

https://github.com/ethul/redis-algebra
Project Organization

Project Organization

com.github.ethul
Source Code Management

Source Code Management

https://github.com/ethul/redis-algebra

Download redis-algebra_2.10

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.ethul/redis-algebra_2.10/ -->
<dependency>
    <groupId>com.github.ethul</groupId>
    <artifactId>redis-algebra_2.10</artifactId>
    <version>0.1.3</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.ethul/redis-algebra_2.10/
implementation 'com.github.ethul:redis-algebra_2.10:0.1.3'
// https://jarcasting.com/artifacts/com.github.ethul/redis-algebra_2.10/
implementation ("com.github.ethul:redis-algebra_2.10:0.1.3")
'com.github.ethul:redis-algebra_2.10:jar:0.1.3'
<dependency org="com.github.ethul" name="redis-algebra_2.10" rev="0.1.3">
  <artifact name="redis-algebra_2.10" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.ethul', module='redis-algebra_2.10', version='0.1.3')
)
libraryDependencies += "com.github.ethul" % "redis-algebra_2.10" % "0.1.3"
[com.github.ethul/redis-algebra_2.10 "0.1.3"]

Dependencies

compile (2)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.10.4
org.scalaz : scalaz-core_2.10 jar 7.1.0

test (1)

Group / Artifact Type Version
org.specs2 : specs2_2.10 jar 2.4

Project Modules

There are no modules declared in this project.

Redis Algebra

A Redis library for Scala that is built on Scalaz's free monad implementation, designed in the spirit of Swierstra's Data types a la carte. The library is intended to be used in combination with other free monad based libraries to build rich algebras tailored to the user's needs.

The functions that this library provides correspond to the list of Redis commands. In order to run programs that have been written using this library, an interpreter needs to be implemented to handle each of the commands. There is no interpreter included by default; however, one may be made available in a separate repository. Interpreters may be interchanged freely based on the user's desired behaviour. For instance, a non-blocking interpreter that sends commands to Redis may be used in production, while an interpreter that uses an in-memory representation may be used when running tests.

Install

Releases and snapshots of the Redis Algebra library are published to the Sonatype OSS Repository Hosting Service. The necessary SBT Resolvers may be added as follows to your SBT build file.

resolvers += "Sonatype releases" at "http://oss.sonatype.org/content/repositories/releases/"

resolvers += "Sonatype snapshots" at "http://oss.sonatype.org/content/repositories/snapshots/"

Usage

import scala.language.implicitConversions
import scalaz.{CharSet, NonEmptyList}, NonEmptyList.nels
import scalaz.std.list._
import scalaz.syntax.{Ops, monad, traverse}, monad._, traverse._

import redis.algebra.{F, R}
import redis.algebra.all._

val e0 =
  set[R]("key".utf8, "value".utf8) >>
  get[R]("key".utf8)

val e1 =
  set[R]("counter".utf8, 100L.utf8) >>
  incr[R]("counter".utf8) >>
  incr[R]("counter".utf8) >>
  incrby[R]("counter".utf8, 10L)

val e2 =
  List("first".utf8, "second".utf8, "third".utf8).map(a => rpush[R]("messages".utf8, nels(a))).sequenceU >>
  lrange[R]("messages".utf8, 0, 2)

implicit def StringToStringOps(a: String): StringOps = new StringOps { val self = a }

implicit def LongToStringOps(a: Long): StringOps = new StringOps { val self = a.toString }

sealed abstract class StringOps extends Ops[String] { final def utf8 = self.getBytes(CharSet.UTF8).toIndexedSeq }

Versions

Version
0.1.3
0.1.1