Swiftpack.co - Package - IBM-Swift/Kitura-redis

KituraRedis

Build Status

Swift Redis library

KituraRedis is a Swift library for interacting with a Redis database using.

It is dependent on the BlueSocket module.

Swift version

The latest version of Kitura-redis requires Swift 4.0.3. You can download this version of the Swift binaries by following this link. Compatibility with other Swift versions is not guaranteed.

Build:

  • swift build

Running Tests:

This example uses Docker to run Redis detached with the required password defined in Tests/SwiftRedis/password.txt.

  • docker run -d -p 6379:6379 redis:alpine redis-server --requirepass password123
  • swift test

Usage:

import Foundation
import SwiftRedis

let redis = Redis()

redis.connect(host: "localhost", port: 6379) { (redisError: NSError?) in
    if let error = redisError {
        print(error)
    }
    else {
        print("Connected to Redis")
        // set a key
        redis.set("Redis", value: "on Swift") { (result: Bool, redisError: NSError?) in
            if let error = redisError {
                print(error)
            }
            // get the same key
            redis.get("Redis") { (string: RedisString?, redisError: NSError?) in
                if let error = redisError {
                    print(error)
                }
                else if let string = string?.asString {
                    print("Redis \(string)")
                }
            }
        }
    }
}

Github

link
Stars: 52
Help us keep the lights on

Dependencies

Used By

Total:

Releases

1.8.0 - Sep 11, 2017

0.6.0 - Mar 23, 2016

0.4.0 - Mar 8, 2016

0.2.0 - Feb 22, 2016

Basic functionality for interacting with a Redis database.