Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Kitura/Kitura-Session-Redis
Kitura-Session store using Redis as the backing store
https://github.com/Kitura/Kitura-Session-Redis
Last synced: 3 months ago
JSON representation
Kitura-Session store using Redis as the backing store
- Host: GitHub
- URL: https://github.com/Kitura/Kitura-Session-Redis
- Owner: Kitura
- License: apache-2.0
- Created: 2016-05-18T12:25:17.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2020-10-09T02:03:46.000Z (about 4 years ago)
- Last Synced: 2024-07-24T18:17:32.430Z (3 months ago)
- Language: Swift
- Size: 254 KB
- Stars: 3
- Watchers: 21
- Forks: 9
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Kitura-Session-Redis
Kitura-Session store using Redis as the backing store## Summary
[Kitura-Session](https://github.com/Kitura/Kitura-Session) store using [Redis](http://redis.io/) as the backing store## Table of Contents
* [Swift version](#swift-version)
* [API](#api)
* [License](#license)## Swift version
The latest version of Kitura-Session-Redis requires **Swift 4.0 or newer**. You can download this version of the Swift binaries by following this [link](https://swift.org/download/). Compatibility with other Swift versions is not guaranteed.## API
In order to use Redis as session store, create an instance of `RedisStore`, and pass it to `Session` constructor:```swift
import KituraSession
import KituraSessionRedislet redisStore = RedisStore(redisHost: host, redisPort: port, redisPassword: password)
let session = Session(secret: , store: redisStore)
````RedisStore` constructor requires Redis server host and port. The rest of the parameters are optional:
```swift
init (redisHost: String, redisPort: Int32, redisPassword: String?=nil, ttl: Int = 3600, db: Int = 0, keyPrefix: String = "s:")
```You can set Redis password in `redis.conf` file:
```
requirepass
```
The maximum number of databases is also set in `redis.conf` file:
```
databases
```
The `db` passed to the constructor must be between 0 and this number minus 1.## Swift Test Setup
To run swift test for `Kitura-Session-Redis` you must first set up Redis.
From the Kitura-Session-Redis directory, run the following commands:#### MacOS
```
brew install redis --build-from-source || brew outdated redis || brew upgrade redis
export REDIS_CONF_FILE=/usr/local/etc/redis.conf
password=$(head -n 1 “/Tests/KituraSessionRedisTests/password.txt")
sudo perl -pi -e "s/# requirepass foobared/requirepass ${password}/g" $REDIS_CONF_FILE
redis-server $REDIS_CONF_FILE
```#### Linux
```
sudo apt-get update -y
sudo apt-get install -y redis-server
export REDIS_CONF_FILE=/etc/redis/redis.conf
sudo chmod go+x /etc/redis/
sudo chmod go+r $REDIS_CONF_FILE
password=$(head -n 1 “/Tests/KituraSessionRedisTests/password.txt")
sudo perl -pi -e "s/# requirepass foobared/requirepass ${password}/g" $REDIS_CONF_FILE
sudo service redis-server restart
```Then run `swift test`.
## License
This library is licensed under Apache 2.0. Full license text is available in [LICENSE](LICENSE.txt).