Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dgzlopes/xk6-redis
A k6 extension for Redis.
https://github.com/dgzlopes/xk6-redis
k6 k6-extension redis xk6
Last synced: about 2 months ago
JSON representation
A k6 extension for Redis.
- Host: GitHub
- URL: https://github.com/dgzlopes/xk6-redis
- Owner: dgzlopes
- License: apache-2.0
- Archived: true
- Created: 2020-11-18T22:17:16.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2022-10-27T11:15:33.000Z (about 2 years ago)
- Last Synced: 2024-07-30T21:05:28.116Z (5 months ago)
- Topics: k6, k6-extension, redis, xk6
- Language: Go
- Homepage:
- Size: 271 KB
- Stars: 12
- Watchers: 3
- Forks: 12
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# DEPRECATED
Redis support is now part of k6. Please, check our [docs](https://k6.io/docs/javascript-api/k6-experimental/redis/), and the [release notes](https://github.com/grafana/k6/blob/master/release%20notes/v0.39.0.md#k6experimental-js-modules).
# xk6-redis
This is a [k6](https://go.k6.io/k6) extension using the [xk6](https://github.com/grafana/xk6) system.
## Build
To build a `k6` binary with this extension, first ensure you have the prerequisites:
- [Go toolchain](https://go101.org/article/go-toolchain.html)
- GitThen:
1. Install `xk6`:
```shell
$ go install go.k6.io/xk6/cmd/xk6@latest
```2. Build the binary:
```shell
$ xk6 build --with github.com/dgzlopes/xk6-redis@latest
```## Example
```javascript
import redis from 'k6/x/redis';const client = redis.newClient();
export function setup() {
redis.set(client,"snake","camel",0)
redis.set(client,"foo",100,10)
}export default function () {
console.log(redis.get(client,"snake"))
console.log(redis.get(client,"foo"))
if (redis.do(client,"PING","bzzz") == "bzzz"){
console.log("PONG!")
}
}export function teardown () {
redis.del(client,"foo")
}```
Result output:
```
$ ./k6 run script.js/\ |‾‾| /‾‾/ /‾‾/
/\ / \ | |/ / / /
/ \/ \ | ( / ‾‾\
/ \ | |\ \ | (‾) |
/ __________ \ |__| \__\ \_____/ .ioexecution: local
script: ../example.js
output: -scenarios: (100.00%) 1 scenario, 1 max VUs, 10m30s max duration (incl. graceful stop):
* default: 1 iterations for each of 1 VUs (maxDuration: 10m0s, gracefulStop: 30s)INFO[0000] bar source=console
INFO[0000] PONG! source=consolerunning (00m00.0s), 0/1 VUs, 1 complete and 0 interrupted iterations
default ✓ [======================================] 1 VUs 00m00.0s/10m0s 1/1 iters, 1 per VU█ setup
█ teardown
data_received........: 0 B 0 B/s
data_sent............: 0 B 0 B/s
iteration_duration...: avg=544.06µs min=428.6µs med=597.41µs max=606.18µs p(90)=604.43µs p(95)=605.31µs
iterations...........: 1 46.10603/s
```