swift-nio-redis/Sources/Redis
Helge Hess 5fef65eb2f
Initial drop
2018-04-11 00:27:29 +02:00
..
README.md Initial drop 2018-04-11 00:27:29 +02:00
RedisClient.swift Initial drop 2018-04-11 00:27:29 +02:00
RedisClientOptions.swift Initial drop 2018-04-11 00:27:29 +02:00
RedisCommand.swift Initial drop 2018-04-11 00:27:29 +02:00
RedisCommandTarget.swift Initial drop 2018-04-11 00:27:29 +02:00
RedisPrint.swift Initial drop 2018-04-11 00:27:29 +02:00
RedisRetry.swift Initial drop 2018-04-11 00:27:29 +02:00
RedisTypeTransformable.swift Initial drop 2018-04-11 00:27:29 +02:00

README.md

SwiftNIO Redis - Client

Designed after node_redis.

Sample

import Redis

let client = Redis.createClient()

client.set("foo_rand00000", "OK")

client.get("foo_rand00000") { err, reply in
    print("Reply:", reply)
}

PubSub Sample

import Redis

let sub = Redis.createClient(), pub = Redis.createClient()
var msg_count = 0

sub.onSubscribe { channel, count in
  pub.publish("a nice channel", "I am sending a message.")
  pub.publish("a nice channel", "I am sending a second message.")
  pub.publish("a nice channel", "I am sending my last message.")
}

sub.onMessage { channel, message in
  print("sub channel \(channel):", message)
  msg_count += 1
  if msg_count == 3 {
    sub.unsubscribe()
    sub.quit()
    pub.quit()
  }
}

sub.subscribe("a nice channel")

Limitations:

  • no auth
  • reconnect strategy needs to be implemented
  • only basic commands
  • no client.multi or client.batch
  • no URL