-
-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #60 from vapor/updates
stream fix + readme + circle cleanup
- Loading branch information
Showing
4 changed files
with
36 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,114 +1,20 @@ | ||
# Redis | ||
|
||
[![Swift](http://img.shields.io/badge/swift-3.1-brightgreen.svg)](https://swift.org) | ||
[![CircleCI](https://circleci.com/gh/vapor/redis.svg?style=shield)](https://circleci.com/gh/vapor/redis) | ||
[![Slack Status](http://vapor.team/badge.svg)](http://vapor.team) | ||
|
||
Redis communication protocol specification: [http://redis.io/topics/protocol](http://redis.io/topics/protocol) | ||
|
||
A Swift wrapper for Redis. | ||
|
||
- [x] Pure Swift | ||
- [x] Pub/sub | ||
- [x] Pipelines | ||
- [x] Fast (Byte based) | ||
|
||
## 📖 Examples | ||
|
||
```swift | ||
import Redis | ||
|
||
let client = try TCPClient() | ||
|
||
try client.command(.set, ["FOO", "BAR"]) | ||
|
||
let res = try client.command(.get, ["FOO"]) | ||
print(res?.string) // "BAR" | ||
``` | ||
|
||
### Custom Host / Port | ||
|
||
Setting a custom hostname and port for the TCP connection is easy. | ||
|
||
```swift | ||
import Redis | ||
|
||
let client = try TCPClient( | ||
hostname: "127.0.0.1", | ||
port: 6379 | ||
) | ||
``` | ||
|
||
### Password | ||
|
||
Set the password to authorize the connection upon init. | ||
|
||
```swift | ||
import Redis | ||
|
||
let client = try TCPClient(password: "secret") | ||
``` | ||
|
||
### Pipeline | ||
|
||
Pipelines can be used to send multiple queries at once and receive their responses as an array. | ||
|
||
```swift | ||
let client = try TCPClient() | ||
let results = try client | ||
.makePipeline() | ||
.enqueue(.set, ["FOO", "BAR"]) | ||
.enqueue(.set, ["Hello", "World"]) | ||
.enqueue(.get, ["Hello"]) | ||
.enqueue(.get, ["FOO"]) | ||
.execute() | ||
|
||
print(results) // ["OK", "OK", "World", "Bar"] | ||
``` | ||
|
||
### Pub/Sub | ||
|
||
Publish and subscribe is a mechanism by which two processes or threads can share data. | ||
|
||
Note: `subscribe` will block and loop forever. Use on a background thread if you want to continue execution on the main thread. | ||
|
||
```swift | ||
background { | ||
let client = try TCPClient() | ||
try client.subscribe(channel: "vapor") { data in | ||
print(data) // "FOO" | ||
} | ||
} | ||
|
||
let client = try TCPClient() | ||
try client.publish(channel: "vapor", "FOO") | ||
``` | ||
|
||
### Ping | ||
|
||
For testing the connection. | ||
|
||
```swift | ||
let client = try TCPClient() | ||
try client.command(.ping) | ||
print(res?.string) // "PONG" | ||
``` | ||
|
||
## 📖 Documentation | ||
|
||
Visit the Vapor web framework's [documentation](http://docs.vapor.codes) for instructions on how to use this package. | ||
|
||
## 💧 Community | ||
|
||
Join the welcoming community of fellow Vapor developers in [slack](http://vapor.team). | ||
|
||
## 🔧 Compatibility | ||
|
||
This package has been tested on macOS and Ubuntu. | ||
|
||
## :alien: Original Author | ||
|
||
[![Blog](https://img.shields.io/badge/blog-honzadvorsky.com-green.svg)](http://honzadvorsky.com) | ||
[![Twitter Czechboy0](https://img.shields.io/badge/twitter-czechboy0-green.svg)](http://twitter.com/czechboy0) | ||
|
||
Honza Dvorsky - http://honzadvorsky.com, [@czechboy0](http://twitter.com/czechboy0) | ||
<p align="center"> | ||
<img src="https://cloud.githubusercontent.com/assets/1342803/24753711/a2e633a8-1ad3-11e7-80ee-4b79ebb077cc.png" width="320" alt="Redis"> | ||
<br> | ||
<br> | ||
<a href="http://beta.docs.vapor.codes/redis/package/"> | ||
<img src="http://img.shields.io/badge/read_the-docs-92A8D1.svg" alt="Documentation"> | ||
</a> | ||
<a href="http://vapor.team"> | ||
<img src="http://vapor.team/badge.svg" alt="Slack Team"> | ||
</a> | ||
<a href="LICENSE"> | ||
<img src="http://img.shields.io/badge/license-MIT-brightgreen.svg" alt="MIT License"> | ||
</a> | ||
<a href="https://circleci.com/gh/vapor/redis"> | ||
<img src="https://circleci.com/gh/vapor/redis.svg?style=shield" alt="Continuous Integration"> | ||
</a> | ||
<a href="https://swift.org"> | ||
<img src="http://img.shields.io/badge/swift-3.1-brightgreen.svg" alt="Swift 3.1"> | ||
</a> | ||
</center> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,14 @@ | ||
machine: | ||
services: | ||
- redis | ||
dependencies: | ||
override: | ||
- eval "$(curl -sL https://apt.vapor.sh)" | ||
- sudo apt-get install vapor cmysql | ||
- sudo chmod -R a+rx /usr/ | ||
test: | ||
override: | ||
- eval "$(curl -sL swift.vapor.sh/ci-3.1)" | ||
- swift build | ||
- swift build -c release | ||
- swift test | ||
|