Kitura-redis

 收藏    我在用   0 人在用
 -  null

Swift Redis library

 GitHub     下载     同步

25    50    11    over 2 years前

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.

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)")
                }
            }
        }
    }
}

 
No Reply at the moment.
需要 Sign In 后方可回复, 如果你还没有账号请点击这里 Sign Up