RedShot is a minimalistic Swift client library for the Redis database.
Redshot is dependency free.
To add RedShot in your projects.
Add this in your Package.swift
:
.Package(url: "https://github.com/bermudadigitalstudio/Redshot.git", majorVersion: 0)
You can connect to Redis by instantiating the Redis
class :
import RedShot
let redis = try Redis(hostname: "localhost", port: 6379)
To connect to a password protected Redis instance, use:
let redis = try Redis(hostname: "localhost", port: 6379, password: "mypassword")
The Redis class exposes methods that are named identical to the commands they execute. The arguments these methods accept are often identical to the arguments specified on the Redis website. For instance, SET
and GET
commands can be called like this:
try redis.set(key: "mycounter", value: "479")
let myCounter = try redis.get(key: "mycounter")
print(myCounter)
RedShot's unit test require a running Redis database with a password.
Redis instance can be launch with Docker :
docker run -d -p 6379:6379 redis:latest --requirepass password123
host: "localhost"
port: 6379
The source code is formatted using SwiftLint and all commits & PRs need to be without any SwiftLint warnings or errors.
RedShot is released under the MIT License.