All Projects → Kitura → Kitura Redis

Kitura / Kitura Redis

Licence: apache-2.0
Swift Redis library

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Kitura Redis

Redis Marshal
Lightweight Redis data exploration tool
Stars: ✭ 16 (-80.95%)
Mutual labels:  database, redis
Docker Redis Cluster
Dockerfile for Redis Cluster (redis 3.0+)
Stars: ✭ 1,035 (+1132.14%)
Mutual labels:  database, redis
Redix
a persistent real-time key-value store, with the same redis protocol with powerful features
Stars: ✭ 907 (+979.76%)
Mutual labels:  database, redis
Laravel Eloquent Query Cache
Adding cache on your Laravel Eloquent queries' results is now a breeze.
Stars: ✭ 529 (+529.76%)
Mutual labels:  database, redis
Nodbi
Document DBI connector for R
Stars: ✭ 56 (-33.33%)
Mutual labels:  database, redis
Gin Boilerplate
The fastest way to deploy a restful api's with Gin Framework with a structured project that defaults to PostgreSQL database and JWT authentication middleware stored in Redis
Stars: ✭ 559 (+565.48%)
Mutual labels:  database, redis
Walrus
Lightweight Python utilities for working with Redis
Stars: ✭ 846 (+907.14%)
Mutual labels:  database, redis
Nohm
node.js object relations mapper (orm) for redis
Stars: ✭ 462 (+450%)
Mutual labels:  database, redis
Nodejs Driver
DataStax Node.js Driver for Apache Cassandra
Stars: ✭ 1,074 (+1178.57%)
Mutual labels:  database, client
Biota
A simple database framework for Fauna
Stars: ✭ 54 (-35.71%)
Mutual labels:  database, client
Faunadb Js
Javascript driver for FaunaDB
Stars: ✭ 498 (+492.86%)
Mutual labels:  database, client
Faunadb Python
Python driver for FaunaDB
Stars: ✭ 75 (-10.71%)
Mutual labels:  database, client
Csharp Driver
DataStax C# Driver for Apache Cassandra
Stars: ✭ 477 (+467.86%)
Mutual labels:  database, client
Java Knowledge Mind Map
【🌱🌱Java服务端知识技能图谱】用思维脑图梳理汇总Java服务端知识技能
Stars: ✭ 787 (+836.9%)
Mutual labels:  database, redis
Redislite
Redis in a python module.
Stars: ✭ 464 (+452.38%)
Mutual labels:  database, redis
Perfect Redis
A Swift client for Redis.
Stars: ✭ 26 (-69.05%)
Mutual labels:  database, redis
Lada Cache
A Redis based, fully automated and scalable database cache layer for Laravel
Stars: ✭ 424 (+404.76%)
Mutual labels:  database, redis
Ruby Pg
A PostgreSQL client library for Ruby
Stars: ✭ 446 (+430.95%)
Mutual labels:  database, client
Faunadb Jvm
Scala and Java driver for FaunaDB
Stars: ✭ 50 (-40.48%)
Mutual labels:  database, client
Tidis
Distributed transactional NoSQL database, Redis protocol compatible using tikv as backend
Stars: ✭ 1,182 (+1307.14%)
Mutual labels:  database, redis

Kitura

APIDoc Build Status - Master macOS Linux Apache 2 Slack Status

KituraRedis

KituraRedis is a pure Swift client for interacting with a Redis database.

Swift version

The latest version of Kitura-redis requires Swift 4.0.3 or later. You can download this version of the Swift binaries by following this link. Compatibility with other Swift versions is not guaranteed.

Usage

Add dependencies

Add the Kitura-redis package to the dependencies within your application’s Package.swift file. Substitute "x.x.x" with the latest Kitura-redis release.

.package(url: "https://github.com/Kitura/Kitura-redis.git", from: "x.x.x")

Add SwiftRedis to your target's dependencies:

.target(name: "example", dependencies: ["SwiftRedis"]),

Import package

import SwiftRedis

Redis installation

To test Kitura-redis locally you need to install Redis.

macOS

brew install redis

To start redis as a background service and have the service restarted at login:

brew services start redis

Or, if you don't want redis running as a background service:

redis-server /usr/local/etc/redis.conf

Example

This example shows you how to connect and make calls to Redis from Swift.

Create simple Swift executable

Create a directory for this project, change into it and then initialize the project:

$ mkdir exampleRedis && cd exampleRedis
$ swift package init --type executable

Add Kitura-redis as a dependency as described above in "Add dependencies".

Now, edit your main.swift file to contain:

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

Next, build the program and run it (either within Xcode or on the command line):

$ swift build
$ .build/debug/redisExample

You should see:

$ Connected to Redis
$ Redis on Swift

This shows that we've connected to Redis, set a string value for a key and then successfully retrieved the value for that key.

Contributing

Contributions to the Kitura-redis project are welcome. You will want to be able to test your changes locally before submitting a pull request.

The tests require a Redis server to be accessible locally on the default port (6379). If you do not wish to install Redis permanently, you can use Docker to run a temporary instance locally as follows:

docker run -d -p 6379:6379 redis:alpine redis-server --requirepass password123

The password specified above must match the one defined in Tests/SwiftRedis/password.txt. Then you can run the tests as normal, either via Xcode or with:

swift test

API Documentation

For more information visit our API reference.

Community

We love to talk server-side Swift, and Kitura. Join our Slack to meet the team!

License

This library is licensed under Apache 2.0. Full license text is available in LICENSE.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].