Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/j5ik2o/reactive-redis
Akka-Stream based Redis Client for Scala
https://github.com/j5ik2o/reactive-redis
akka akka-streams redis redis-client scala
Last synced: 1 day ago
JSON representation
Akka-Stream based Redis Client for Scala
- Host: GitHub
- URL: https://github.com/j5ik2o/reactive-redis
- Owner: j5ik2o
- License: mit
- Created: 2016-09-17T09:55:33.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2023-12-15T08:51:34.000Z (11 months ago)
- Last Synced: 2024-05-02T01:17:15.383Z (6 months ago)
- Topics: akka, akka-streams, redis, redis-client, scala
- Language: Scala
- Homepage:
- Size: 3.64 MB
- Stars: 3
- Watchers: 6
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# reactive-redis
[![CircleCI](https://circleci.com/gh/j5ik2o/reactive-redis.svg?style=shield&circle-token=b858c698c54b46769e933d7ee7fd55209234bae1)](https://circleci.com/gh/j5ik2o/reactive-redis)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.j5ik2o/reactive-redis-core_2.12/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.github.j5ik2o/reactive-redis-core_2.12)
[![Scaladoc](http://javadoc-badge.appspot.com/com.github.j5ik2o/reactive-redis-core_2.12.svg?label=scaladoc)](http://javadoc-badge.appspot.com/com.github.j5ik2o/reactive-redis-core_2.12/com/github/j5ik2o/reactive/redis/index.html?javadocio=true)
[![License: MIT](http://img.shields.io/badge/license-MIT-orange.svg)](LICENSE)Akka-Stream based Redis Client for Scala
## Concept
- Transport is akka-stream 2.5.x.
- Response parser is fastparse.
- monix.eval.Task support.## Installation
Add the following to your sbt build (Scala 2.11.x, 2.12.x):
### Release Version
```scala
resolvers += "Sonatype OSS Release Repository" at "https://oss.sonatype.org/content/repositories/releases/"libraryDependencies += "com.github.j5ik2o" %% "reactive-redis-core" % "1.0.21"
```### Snapshot Version
```scala
resolvers += "Sonatype OSS Snapshot Repository" at "https://oss.sonatype.org/content/repositories/snapshots/"libraryDependencies += "com.github.j5ik2o" %% "reactive-redis-core" % "1.0.22-SNAPSHOT"
```## Support Commands
- Cluster
Command
Support
CLUSTER ADDSLOTS
TODO
CLUSTER ADDSLOTS
TODO
CLUSTER ADDSCLUSTER COUNT-FAILURE-REPORTSLOTS
TODO
CLUSTER COUNTKEYSINSLOT
TODO
CLUSTER DELSLOTS
TODO
CLUSTER FAILOVER
TODO
CLUSTER FORGET
TODO
CLUSTER GETKEYSINSLOT
TODO
CLUSTER INFO
TODO
CLUSTER KEYSLOT
TODO
CLUSTER MEET
TODO
CLUSTER NODES
TODO
CLUSTER REPLICATE
TODO
CLUSTER RESET
TODO
CLUSTER SAVECONFIG
TODO
CLUSTER SET-CONFIG-EPOCH
TODO
CLUSTER SETSLOT
TODO
CLUSTER SLAVES
TODO
CLUSTER SLOTS
TODO
READONLY
TODO
READWRITE
TODO
- Connection
Command
Support
AUTH
Supported
ECHO
Supported
PING
Supported
QUIT
Supported
SELECT
Supported
SWAPDB
Supported
- Geo
Command
Support
GEOADD
TODO
GEODIST
TODO
GEOHASH
TODO
GEOPOS
TODO
GEORADIUS
TODO
GEORADIUSBYMEMBER
TODO
- Hashes
Command
Support
HDEL
Supported
HEXISTS
Supported
HGET
Supported
HGETALL
Supported
HINCRBY
TODO
HINCRBYFLOAT
TODO
HKEYS
TODO
HLEN
TODO
HMGET
TODO
HMSET
TODO
HSCAN
TODO
HSET
Supported
HSETNX
Supported
HSTRLEN
TODO
HVALS
TODO
- HyperLogLog
Command
Support
PFADD
TODO
PFCOUNT
TODO
PFMERGE
TODO
- Keys
Command
Support
DEL
Supported
DUMP
Supported
EXISTS
Supported
EXPIRE
Supported
EXPIREAT
Supported
KEYS
Supported
MIGRATE
Supported
MOVE
Supported
OBJECT
Supported
PERSIST
Supported
PEXPIRE
Supported
PEXPIREAT
Supported
PTTL
Supported
RANDOMKEY
Supported
RENAME
Supported
RENAMENX
Supported
RESTORE
TODO
SCAN
Supported
SORT
Supported
TOUCH
Supported
TTL
Supported
TYPE
Supported
UNLINK
Supported
WAIT
Supported
- Lists
BLPOP
Supported
BRPOP
Supported
BRPOPLPUSH
Supported
LINDEX
LINSERT
LLEN
Supported
LPOP
LPUSH
Supported
LPUSHX
LRANGE
Supported
LREM
LSET
LTRIM
RPOP
RPOPLPUSH
RPUSH
Supported
RPUSHX
- Pub/Sub
PSUBSCRIBE
PUBLISH
PUBSUB
PUNSUBSCRIBE
SUBSCRIBE
UNSUBSCRIBE
- Scripting
EVAL
EVALSHA
SCRIPT DEBUG
SCRIPT EXISTS
SCRIPT FLUSH
SCRIPT KILL
SCRIPT LOAD
- Server
BGREWRITEAOF
BGSAVE
CLIENT GETNAME
CLIENT KILL
CLIENT LIST
CLIENT PAUSE
CLIENT REPLY
CLIENT SETNAME
COMMAND
COMMAND COUNT
COMMAND GETKEYS
COMMAND INFO
CONFIG GET
CONFIG RESETSTAT
CONFIG REWRITE
CONFIG SET
DBSIZE
DEBUG OBJECT
DEBUG SEGFAULT
FLUSHALL
FLUSHDB
INFO
LASTSAVE
MEMORY DOCTOR
MEMORY HELP
MEMORY MALLOC-STATS
MEMORY PURGE
MEMORY STATS
MEMORY USAGE
MONITOR
ROLE
SAVE
SHUTDOWN
SLAVEOF
SLOWLOG
SYNC
TIME
- Sets
Command
Support
SADD
Supported
SCARD
TODO
SDIFF
TODO
SDIFFSTORE
TODO
SINTER
TODO
SINTERSTORE
TODO
SISMEMBER
TODO
SMEMBERS
TODO
SMOVE
TODO
SPOP
TODO
SRANDMEMBER
TODO
SREM
TODO
SSCAN
TODO
SUNION
TODO
SUNIONSTORE
TODO
- SortedSets
Command
Support
BZPOPMAX
TODO
BZPOPMIN
TODO
ZADD
TODO
ZCARD
TODO
ZCOUNT
TODO
ZINCRBY
TODO
ZINTERSTORE
TODO
ZLEXCOUNT
TODO
ZPOPMAX
TODO
ZPOPMIN
TODO
ZRANGE
TODO
ZRANGEBYLEX
TODO
ZRANGEBYSCORE
TODO
ZRANK
TODO
ZREM
TODO
ZREMRANGEBYLEX
TODO
ZREMRANGEBYRANK
TODO
ZREMRANGEBYSCORE
TODO
ZREVRANGE
TODO
ZREVRANGEBYLEX
TODO
ZREVRANGEBYSCORE
TODO
ZREVRANK
TODO
ZSCAN
TODO
ZSCORE
TODO
ZUNIONSTORE
TODO
- Streams
Command
Support
XADD
TODO
XLEN
TODO
XPENDING
TODO
XRANGE
TODO
XREAD
TODO
XREADGROUP
TODO
XREVRANGE
TODO
- Strings
Command
Support
APPEND
Supported
BITCOUNT
Supported
BITFIELD
Supported
BITOP
Supported
BITPOS
Supported
DECR
Supported
DECRBY
Supported
GET
Supported
GETBIT
Supported
GETRANGE
Supported
GETSET
Supported
INCR
Supported
INCRBY
Supported
INCRBYFLOAT
Supported
MGET
Supported
MSET
Supported
MSETNX
Supported
PSETEX
Supported
SET
Supported
SETBIT
Supported
SETEX
Supported
SETNX
Supported
SETRANGE
Supported
STRLEN
Supported
- Transaction
Command
Support
DISCARD
Supported
EXEC
Supported
MULTI
Supported
UNWATCH
Supported
WATCH
Supported
## Usage### Non connection pooling
```scala
import monix.execution.Scheduler.Implicits.globalimplicit val system = ActorSystem()
val peerConfig = PeerConfig(remoteAddress = new InetSocketAddress("127.0.0.1", 6379))
val connection = RedisConnection(peerConfig)
val client = RedisClient()val result = (for{
_ <- client.set("foo", "bar")
r <- client.get("foo")
} yield r).run(connection).runAsyncprintln(result) // bar
```### Connection pooling
```scala
import monix.execution.Scheduler.Implicits.globalimplicit val system = ActorSystem()
val peerConfig = PeerConfig(remoteAddress = new InetSocketAddress("127.0.0.1", 6379))
val pool = RedisConnectionPool.ofRoundRobin(sizePerPeer = 5, Seq(peerConfig), RedisConnection(_)) // powered by RoundRobinPool
val connection = RedisConnection(connectionConfig)
val client = RedisClient()// Fucntion style
val result1 = pool.withConnectionF{ con =>
(for{
_ <- client.set("foo", "bar")
r <- client.get("foo")
} yield r).run(con)
}.runAsyncprintln(result1) // bar
// Monadic style
val result2 = (for {
_ <- ConnectionAutoClose(pool)(client.set("foo", "bar").run)
r <- ConnectionAutoClose(pool)(client.get("foo").run)
} yield r).run().runAsyncprintln(result2) // bar
```if you want to use other pooling implementation, please select from the following modules.
- reactive-redis-pool-commons (commons-pool2)
- reactive-redis-pool-scala (scala-pool)
- reactive-redis-pool-fop (fast-object-pool)
- reactive-redis-pool-stormpot (stormpot)### Master & Slaves aggregate connection
```scala
import monix.execution.Scheduler.Implicits.globalimplicit val system = ActorSystem()
val masterPeerConfig = PeerConfig(remoteAddress = new InetSocketAddress("127.0.0.1", 6379))
val slavePeerConfigs = Seq(
PeerConfig(remoteAddress = new InetSocketAddress("127.0.0.1", 6380)),
PeerConfig(remoteAddress = new InetSocketAddress("127.0.0.1", 6381)),
PeerConfig(remoteAddress = new InetSocketAddress("127.0.0.1", 6382))
)val connection = new RedisMasterSlavesConnection(
masterConnectionPoolFactory = RedisConnectionPool.ofRoundRobin(sizePerPeer = 2, Seq(masterPeerConfig), RedisConnection(_)),
slaveConnectionPoolFactory = RedisConnectionPool.ofRoundRobin(sizePerPeer = 2, slavePeerConfigs, RedisConnection(_))
)val client = RedisClient()
val result = (for{
_ <- client.set("foo", "bar") // write to master
r <- client.get("foo") // read from any slave
} yield r).run(connection).runAsyncprintln(result) // bar
```## License
MIT License / Copyright (c) 2016 Junichi Kato