Redis

Redis is a Redis client library that can communicate with a Redis database.

What is Redis?

Redis is an in-memory data store used as a database, cache and message broker. It supports most common data structures. Redis is most commonly used for caching data such as sessions and notifications (between multiple servers).

Redis works as a key-value store, but allows querying the keys, unlike most databases.

With and without Vapor

To include it in your package, add the following to your Package.swift file.

  1. // swift-tools-version:4.0
  2. import PackageDescription
  3. let package = Package(
  4. name: "Project",
  5. dependencies: [
  6. ...
  7. .package(url: "https://github.com/vapor/redis.git", .upToNextMajor(from: "3.0.0")),
  8. ],
  9. targets: [
  10. .target(name: "Project", dependencies: ["Redis", ... ])
  11. ]
  12. )

If this is your first time adding a dependency, you should read our introduction to Package.swift.

Use import Redis to access Redis’ APIs.