Swiftpack.co - Package - Mordil/nio-redis

License Build Swift Redis


A non-blocking Swift driver for Redis built with SwiftNIO.

This package defines everything you need to work with Redis through the Redis Seralization Protocol (RESP).


To install NIORedis, just add the package as a dependency in your Package.swift

dependencies: [
    .package(url: "https://github.com/Mordil/nio-redis.git", .upToNextMinor(from: "0.2.0")

and run the following command: swift package resolve

Getting Started

NIORedis is ready to use right after installation.

import NIORedis

let driver = NIORedisDriver(ownershipModel: .internal(threadCount: 2))

let connection = try driver.makeConnection().wait()

let result = try connection.set("my_key", to: "some value")
    .flatMap { return connection.get("my_key" }

print(result) // Optional("some value")


Check out CONTRIBUTING.md for more information on how to help with NIORedis.

It is highly recommended to use Docker to install Redis locally.

docker run -d -p 6379:6379 --name nioredis redis:5

Otherwise, install Redis directly on your machine from Redis.io.


Stars: 3
Help us keep the lights on

Used By



0.4.0 - Mar 19, 2019

Breaking Changes

  • Removed DispatchRedis package (https://github.com/Mordil/nio-redis/commit/5c32b97a0c5cd3e560dd2a7d465b51686915b62a)
  • RedisConnection and RedisPipeline have become protocols. The default implementations have been renamed to NIORedisConnection and NIORedisPipeline (https://github.com/Mordil/nio-redis/commit/6b30127f6b7a3f75cdbeca8f426fe9260bdbe370)
  • The select(_:) command convenience method has been renamed to select(database:) (https://github.com/Mordil/nio-redis/commit/6b30127f6b7a3f75cdbeca8f426fe9260bdbe370)
  • RedisPipeline.enqueue(command:arguments:) has been renamed to RedisPipeline.enqueue(operation:) which is now a closure that provides a RedisCommandExecutor so all of the command convenience methods are made available. (https://github.com/Mordil/nio-redis/commit/6b30127f6b7a3f75cdbeca8f426fe9260bdbe370)
    • Commands are still queued and not executed immediately.
  • RedisConnection.command(_:arguments:) is no longer supported (https://github.com/Mordil/nio-redis/commit/6b30127f6b7a3f75cdbeca8f426fe9260bdbe370)

New Additions

  • swift-log is now added, and default logging implementations have been added (https://github.com/Mordil/nio-redis/commit/73d5930f3413f944c9c209d4e0b276a915f7f34b)
    • Most logging is done with debug
    • Each logging instance can be overridden in constructors of objects that log
    • Each logger uses a NIORedis. prefix in their label
  • RedisCommandExecutor protocol that creates an interface for objects responsible for sending commands (https://github.com/Mordil/nio-redis/commit/6b30127f6b7a3f75cdbeca8f426fe9260bdbe370)
    • NIORedisConnection and NIORedisPipeline both conform to this protocol
  • RESPConvertible conformance to Optional (https://github.com/Mordil/nio-redis/commit/618481fe1eae8208e5d160eba2ecce6978dd606f)
  • New command convenience methods (https://github.com/Mordil/nio-redis/commit/9f505be4d2a16c441d9a2b1d7266a04b4106bfaf)


  • NIORedisConnection.close() to send a "QUIT" command to Redis before closing, and properly checking if the connection has been closed already (https://github.com/Mordil/nio-redis/commit/68254519636bbcd3b882e4b4f63d8cbf2b3e3fb1)

0.3.0 - Mar 14, 2019

0.2.0 - Jan 10, 2019

0.1.0 - Jan 8, 2019