Kreds - a thread-safe, idiomatic, coroutine based Redis client written in 100% Kotlin

Last update: May 22, 2022

Kreds

Maven Central javadoc CI CD Pure Kotlin codecov FOSSA Status Join the chat at https://gitter.im/kreds-redis/community GitHub commit activity GitHub Reliability Rating Maintainability Rating

Kreds is a thread-safe, idiomatic, coroutine based Redis client written in 100% Kotlin.

Why Kreds?

  • Kreds is designed to be EASY to use.
  • Kreds has clean API, clear return types, avoid the dreaded null pointer exception at compile time!
  • Kreds is built around coroutines, providing you an imperative paradigm of programming without blocking threads, futures or callback hell, thanks to Kotlin Coroutines!
  • Run blocking commands without blocking Java threads. (Only the inexpensive coroutines are blocked)
  • Kreds uses Netty under the hood and is truly asynchronous.
  • High throughput.

Use cases

  • Web app cache client: Don't open multiple connections to redis, for each http request, use single connection in a thread-safe manner.
  • Pub/Sub: Subscribe to multiple channels from one or multiple Redis, without being limited by java threads.

Kreds is compatible with redis 6.x.x and above.

Documentation

You can find the user guide and documentation here 🚧

So what can I do with Kreds?

All the following redis features are supported:

  • Commands operating on Strings, Hash, Lists, Keys, Sets, Sorted Sets. ✔️
  • Blocking commands. ✔️
  • Pipelining. ✔️
  • Publish/Subscribe. ✔️
  • Connection handling commands. ✔️
  • Transactions. 🚧 [Implementation done, testing in progress.]

How do I use it?

To use it just:

client.set("foo","100") println("incremented value of foo ${client.incr("foo")}") // prints 101 client.expire("foo",3u) // set expiration to 3 seconds delay(3000) assert(client.get("foo") == null) } }">
launch {
    newClient(Endpoint.from("127.0.0.1:6379")).use { client ->
        client.set("foo","100") 
        println("incremented value of foo ${client.incr("foo")}") // prints 101
        client.expire("foo",3u) // set expiration to 3 seconds
        delay(3000)
        assert(client.get("foo") == null)
    }
}

How to get it?

<dependency>
  <groupId>io.github.crackthecodeabhigroupId>
  <artifactId>kredsartifactId>
  <version>0.7version>
dependency>

Gradle Groovy DSL

implementation 'io.github.crackthecodeabhi:kreds:0.7'

Gradle Kotlin DSL

implementation("io.github.crackthecodeabhi:kreds:0.7")

License

Copyright (c) 2021 Abhijith Shivaswamy

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

FOSSA Status

GitHub

https://github.com/crackthecodeabhi/kreds
You might also like...

Demonstration of Object Pool Design Pattern using Kotlin language and Coroutine

Demonstration of Object Pool Design Pattern using Kotlin language and Coroutine

Object Pool Design Pattern with Kotlin Demonstration of Thread Safe Object Pool Design Pattern using Kotlin language and Coroutine. Abstract The objec

Apr 12, 2022

A simple android Twitter client written in Kotlin

A simple android Twitter client written in Kotlin

Blum Blum is an unofficial, simple, fast Twitter client written in Kotlin. This project is a complete rewrite of the Java version. Screenshot Build To

Oct 8, 2021

Mobile client for official Nextcloud News App written as Kotlin Multiplatform Project

Mobile client for official Nextcloud News App written as Kotlin Multiplatform Project

Newsout Android and iOS mobile client for Nextcloud news App. The Android client is already available to download in the Play Store. F-Droid and Apple

Apr 12, 2022

KTor-Client---Android - The essence of KTor Client for network calls

KTor Client - Android This project encompasses the essence of KTor Client for ne

Jan 18, 2022

Spring Boot project scaffold written in Kotlin, which is based on the Official Guide.

Kotlin-Spring-Boot Spring Boot project scaffold written in Kotlin, which is based on the Official Guide. Development environment Windows choco install

Feb 27, 2022

A complex of libraries and starters for organizing long-polling-based interaction between the client and the server.

A complex of libraries and starters for organizing long-polling-based interaction between the client and the server.

May 8, 2022

Integration Testing Kotlin Multiplatform Kata for Kotlin Developers. The main goal is to practice integration testing using Ktor and Ktor Client Mock

Integration Testing Kotlin Multiplatform Kata for Kotlin Developers. The main goal is to practice integration testing using Ktor and Ktor Client Mock

This kata is a Kotlin multiplatform version of the kata KataTODOApiClientKotlin of Karumi. We are here to practice integration testing using HTTP stub

Mar 3, 2022

KataContacts written in Kotlin. The main goal is to practice Clean Architecture Development

KataContacts written in Kotlin We are here to practice Clean Architecture Development. Clean Architecture is a way of structuring code. We are going t

Jun 3, 2021
Comments
  • 1. How to set to connect Redis cluster

    Hi I want to use this Redis client to connect Redis cluster on K8s. Do I need to set some configuration? for example by using quarkus.redis,.client, I have to add configuration properties like : quarkus.redis.client-type = cluster

    thank you

    Reviewed by yehshuwen at 2022-03-08 07:28
  • 2. Add license scan report and status

    Your FOSSA integration was successful! Attached in this PR is a badge and license report to track scan status in your README.

    Below are docs for integrating FOSSA license checks into your CI:

    Reviewed by fossabot at 2021-12-24 18:51
  • 3. Add a Gitter chat badge to README.md

    crackthecodeabhi/kreds now has a Chat Room on Gitter

    @crackthecodeabhi has just created a chat room. You can visit it here: https://gitter.im/kreds-redis/community.

    This pull-request adds this badge to your README.md:

    Gitter

    If my aim is a little off, please let me know.

    Happy chatting.

    PS: Click here if you would prefer not to receive automatic pull-requests from Gitter in future.

    Reviewed by gitter-badger at 2021-12-24 19:16
  • 4. ERR syntax error on SetOption ULong options

    SetOption throws KredsRedisDataException every time I use ULong options. Example:

    newClient(Endpoint.from("127.0.0.1:${redis.firstMappedPort}")).use { client ->
        client.set("key", "val", SetOption.Builder(exSeconds = 30u).build())
    ...
    ERR syntax error
    io.github.crackthecodeabhi.kreds.protocol.KredsRedisDataException: ERR syntax error
    	at app//io.github.crackthecodeabhi.kreds.protocol.CommandProcessor.decode(Command.kt:69)
    	at app//io.github.crackthecodeabhi.kreds.connection.AbstractKredsClient$execute$suspendImpl$$inlined$withReentrantLock$2.invokeSuspend(ExclusiveObject.kt:49)
    	(Coroutine boundary)
    	at io.github.crackthecodeabhi.kreds.connection.AbstractKredsClient.execute$suspendImpl(Client.kt:151)
    

    client.expire("key", 30u) works without issues.

    Library version: 0.7 Redis server: redis:6.2.7-alpine Kotlin 1.6.10

    Reviewed by istarion at 2022-04-28 13:27
Extensive Redis Pub-Sub wrapper for lettuce written in Kotlin

aware Extensive annotation-based Redis Pub-Sub wrapper for lettuce written in Kotlin. Aware was written to be a replacement for the very dated Banana

May 6, 2022
A simple, lightweight, non-bloated redis client for kotlin and other JVM languages

rekt is a lightweight, non-bloated redis client, primarily written for the kotlin programming language, while also supporting other JVM-based languages, such as Java, Scala, and obviously way more.

May 18, 2022
Multi-thread ZX0 data compressor in Kotlin

ZX0-Kotlin ZX0-Kotlin is a multi-thread implementation of the ZX0 data compressor in Kotlin. Requirements To run this compressor, you must have instal

Apr 14, 2022
100% FOSS keyboard, based on AOSP.
100% FOSS keyboard, based on AOSP.

OpenBoard 100% FOSS keyboard, based on AOSP. Community [matrix] channel Join here Common issues Cannot open settings in MIUI: See issue #46. Contribut

May 17, 2022
An idiomatic Kotlin DSL for creating regular expressions.

Ketex An idiomatic Kotlin DSL for creating regular expressions. For documentation and usage instructions, please take a look at the docs. Here's the m

May 16, 2022
Kotter - aims to be a relatively thin, declarative, Kotlin-idiomatic API that provides useful functionality for writing delightful console applications.
Kotter - aims to be a relatively thin, declarative, Kotlin-idiomatic API that provides useful functionality for writing delightful console applications.

Kotter (a KOTlin TERminal library) aims to be a relatively thin, declarative, Kotlin-idiomatic API that provides useful functionality for writing delightful console applications.

May 24, 2022
A spring-boot project that demonstrates data caching using Redis

A spring-boot project that demonstrates data caching using Redis

Mar 26, 2022
The sample App implements type safe SQL by JOOQ & DB version control by Flyway

The sample App implements type safe SQL by JOOQ & DB version control by Flyway Setup DB(PostgreSQL) $ docker compose up -d Migration $ ./gradlew flywa

Jan 1, 2022
Android Multi Theme Switch Library ,use kotlin language ,coroutine ,and so on ...
Android Multi Theme Switch Library ,use  kotlin language ,coroutine ,and so on ...

Magic Mistletoe Android多主题(换肤)切换框架 背景 时隔四年,在网易换肤之前的思路下,做了几点改进,现在完全通过反射创建View,并且在SkinLoadManager中提供一个configCustomAttrs以支持自定义View的属性插队替换 摈弃了之前的AsyncTask

May 9, 2022
R2DBC Sharding Example with Kotlin Coroutine

R2DBC Sharding Example with Kotlin Coroutine A minimal sharding example with R2DBC and coroutine, where user table is divided into 2 different shards.

Oct 4, 2021