All Projects → kliewkliew → salad

kliewkliew / salad

Licence: Apache-2.0 License
Asynchronous Scala Redis Client supporting Sentinel and Redis Cluster

Programming Languages

scala
5932 projects

Projects that are alternatives of or similar to salad

Ioredis
🚀 A robust, performance-focused, and full-featured Redis client for Node.js.
Stars: ✭ 9,754 (+69571.43%)
Mutual labels:  redis-sentinel, redis-cluster, redis-client
racompass
An advanced GUI for Redis. Modern. Efficient. Fast. A faster and robust Redis management tool. For developers that need to manage data with confidence.It supports Redis modules now!
Stars: ✭ 26 (+85.71%)
Mutual labels:  redis-sentinel, redis-cluster, redis-client
Anotherredisdesktopmanager
🚀🚀🚀A faster, better and more stable redis desktop manager [GUI client], compatible with Linux, Windows, Mac. What's more, it won't crash when loading massive keys.
Stars: ✭ 17,704 (+126357.14%)
Mutual labels:  redis-sentinel, redis-cluster, redis-client
Stackexchange.redis.extensions
Stars: ✭ 419 (+2892.86%)
Mutual labels:  caching, cache, redis-client
redis-developer.github.io
The Home of Redis Developers
Stars: ✭ 28 (+100%)
Mutual labels:  redis-cluster, redis-client, redis-cache
Camellia
camellia framework by netease-im. provider: 1) redis-client; 2) redis-proxy(redis-sentinel/redis-cluster); 3) hbase-client; 4) others
Stars: ✭ 146 (+942.86%)
Mutual labels:  redis-sentinel, redis-cluster, redis-client
Lettuce Core
Advanced Java Redis client for thread-safe sync, async, and reactive usage. Supports Cluster, Sentinel, Pipelining, and codecs.
Stars: ✭ 4,319 (+30750%)
Mutual labels:  redis-sentinel, redis-cluster, redis-client
Redisson
Redisson - Redis Java client with features of In-Memory Data Grid. Over 50 Redis based Java objects and services: Set, Multimap, SortedSet, Map, List, Queue, Deque, Semaphore, Lock, AtomicLong, Map Reduce, Publish / Subscribe, Bloom filter, Spring Cache, Tomcat, Scheduler, JCache API, Hibernate, MyBatis, RPC, local cache ...
Stars: ✭ 17,972 (+128271.43%)
Mutual labels:  cache, redis-cluster, redis-client
Cachingframework.redis
Distributed caching based on StackExchange.Redis and Redis. Includes support for tagging and is cluster-compatible.
Stars: ✭ 209 (+1392.86%)
Mutual labels:  cache, redis-cluster, redis-client
rueidis
A Fast Golang Redis RESP3 client that supports Client Side Caching, Auto Pipelining, Generics OM, RedisJSON, RedisBloom, RediSearch, RedisAI, RedisGears, etc.
Stars: ✭ 422 (+2914.29%)
Mutual labels:  redis-cluster, redis-client, redis-cache
Simple Spring Memcached
A drop-in library to enable memcached caching in Spring beans via annotations
Stars: ✭ 185 (+1221.43%)
Mutual labels:  caching, cache
Haproxy
HAProxy Load Balancer's development branch (mirror of git.haproxy.org)
Stars: ✭ 2,463 (+17492.86%)
Mutual labels:  caching, cache
Cachemanager
CacheManager is an open source caching abstraction layer for .NET written in C#. It supports various cache providers and implements many advanced features.
Stars: ✭ 2,049 (+14535.71%)
Mutual labels:  caching, cache
Libcache
A Lightweight in-memory key:value cache library for Go.
Stars: ✭ 152 (+985.71%)
Mutual labels:  caching, cache
docker-redis-haproxy-cluster
A Redis Replication Cluster accessible through HAProxy running across a Docker Composed-Swarm with Supervisor and Sentinel
Stars: ✭ 44 (+214.29%)
Mutual labels:  redis-sentinel, redis-cluster
Scaffeine
Thin Scala wrapper for Caffeine (https://github.com/ben-manes/caffeine)
Stars: ✭ 195 (+1292.86%)
Mutual labels:  caching, cache
td-redis-operator
一款强大的云原生redis-operator,经过大规模生产级运行考验,支持分布式集群、支持主备切换等缓存集群解决方案…The powerful cloud-native redis-operator, which has passed the test of large-scale production-level operation, supports distributed clusters and active/standby switching ...
Stars: ✭ 327 (+2235.71%)
Mutual labels:  redis-sentinel, redis-cluster
Nuster
A high performance HTTP proxy cache server and RESTful NoSQL cache server based on HAProxy
Stars: ✭ 1,825 (+12935.71%)
Mutual labels:  caching, cache
cachegrand
cachegrand is an open-source fast, scalable and secure Key-Value store, also fully compatible with Redis protocol, designed from the ground up to take advantage of modern hardware vertical scalability, able to provide better performance and a larger cache at lower cost, without losing focus on distributed systems.
Stars: ✭ 87 (+521.43%)
Mutual labels:  caching, redis-cache
aioredis-cluster
Redis Cluster support extension for aioredis
Stars: ✭ 21 (+50%)
Mutual labels:  redis-cluster, redis-client

Salad

Salad wraps the lettuce async and sync Java API to provide an idiomatic API for Scala applications.

Efficient serdes (serializer-deserializers) are provided to encode keys and values as plain byte-arrays or Snappy-compressed byte-arrays. CompactByteArraySerdes and SnappySerdes will also compact numeric values to the smallest possible lossless representation.

Single-node Redis, master-slave Sentinel configurations, and sharded Redis Cluster configurations are supported.

Salad also ensures that all exceptions thrown by lettuce can be mapped over in Scala futures. If you used lettuce directly, exceptions in lettuce might not trigger Future.failed in Scala.

Usage

SaladAPI is the base wrapper around the lettuce API. It can be decorated with various wrappers that add additional functionality.

Instantiate Lettuce API

val client = RedisClient.create("redis://localhost")
val lettuceAPI = client.connect(ByteArrayCodec.INSTANCE).async

Instantiate Salad Wrapper

If the key can be a string, byte-array, or a numeric type:

import redis.serde.SnappySerdes._
val saladAPI =
  new SaladAPI(lettuceAPI)

If the unencoded key will always be a (compressable) string and the value can be any type:

import redis.serde.SnappySerdes._
val saladAPI =
  new SaladStringKeyAPI(
    new SaladAPI(lettuceAPI))

If the unencoded key will always be an uncompressable string and the value can be any type:

import redis.serde.SnappySerdes._
val saladAPI =
  new SaladUIIDKeyAPI(
    new SaladAPI(lettuceAPI))

If the strings and byte-array values are not compressible while using SaladStringKeyAPI or SaladUIIDKeyAPI, import CompactByteArraySerdes to only compact numeric types.

Use Salad

To use Snappy compression for strings and byte-arays (and compaction for numeric types):

val got: Future[Option[Int]] =
  saladAPI.get[Int]("test")
    .map(valueOpt => valueOpt.map(_ + 1))

However, if the key string is a uuid, there may not be a lot of repetition in the key and thus compression will only add overhead. In that case, you can pass the key and value serdes explicitly.

val got: Future[Option[Int]] =
  saladAPI.get[Int]("test")
      (redis.serde.ByteArraySerdes.stringSerde,
       redis.serde.CompactByteArraySerdes.intSerde)
    .map(valueOpt => valueOpt.map(_ + 1))

If the key is always a string UIID and the value is always numeric or a compressable string or byte-array, you can use the simplified SaladUIIDKeyAPI.

You must ensure that a serde pair is used symmetrically for mutating and accessing a key-value pair.

Serde-Codec Choices

The lettuce codec determines the data is encoded over the wire. Each connection may have one codec. You can create multiple connections with different codecs, sharing underlying client resources. But with interchangeable serdes, that is no longer necessary.

The serde determines how various Scala types are serialized to the codec format and provides type safety to the API. Each interaction with Redis can use a different serde.

The recommended pair is ByteArrayCodec with SnappySerdes or CompactByteArraySerdes (for strings that will not compress well).

CompressionCodec is not recommended as it will attempt to compress singular numeric types which just adds CPU and byte-size overhead.

String serdes are also provided if you require readable keys/values.

ByteArrayCodec

  • ByteArraySerdes
  • CompactByteArraySerdes
  • SnappySerdes

CompressionCodec

  • ByteArraySerdes
  • CompactByteArraySerdes

StringCodec, Utf8StringCodec

  • StringSerdes

Decorators

Configuration

Decorators are configurable by setting a configuration file for the app.

-Dconfig.file=src/main/resources/application.conf

Exception Handling

To ensure that exceptions are thrown when all Redis nodes go down, use the SaladTimeoutAPI decorator.

import scala.concurrent.duration._
val saladAPI =
  new SaladUIIDKeyAPI(
    new SaladTimeoutAPI(
      new SaladAPI(lettuceAPI),
      500.milliseconds))

If you omit the timeout duration parameter, you can specify the timeout (milliseconds) in your configuration file.

ie.

salad.request-timeout = 200

Logging

To log commands to sl4j, use the SaladLoggingAPI decorator.

import scala.concurrent.duration._
val saladAPI =
  new SaladUIIDKeyAPI(
    new SaladLoggingAPI(
      new SaladTimeoutAPI(
        new SaladAPI(lettuceAPI),
        500.milliseconds)))

By default: success and failure are logged to DEBUG and WARN. The default log levels can be overriden in the configuration file.

ie.

salad {
  logging {
    success = "INFO"
    failure = "ERROR"
  }
}

SBT

TODO: publish jars to Maven repo

Salad depends on lettuce 5.x.

libraryDependencies += "biz.paluch.redis" % "lettuce" % "5.0.0.Beta1"

Netty Version Conflict

If the Netty version of lettuce conflicts with your application (ie. Play 2.5), add an exclusion rule to lettuce.

libraryDependencies += "biz.paluch.redis" % "lettuce" % "5.0.0.Beta1" excludeAll ExclusionRule(organization = "io.netty")

If this doesn't work, you may need a lettuce jar with shaded dependencies.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].