Skip to content

Commit

Permalink
Adapt Client methods examples to use the new constructor syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
oleiade committed Nov 15, 2023
1 parent 0fca107 commit 5f5c26f
Show file tree
Hide file tree
Showing 40 changed files with 40 additions and 320 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,8 @@ Decrements the number stored at `key` by one. If the key does not exist, it is s
```javascript
import redis from 'k6/experimental/redis';

// Get the redis instance(s) address and password from the environment
const redis_addrs = __ENV.REDIS_ADDRS || '';
const redis_password = __ENV.REDIS_PASSWORD || '';

// Instantiate a new redis client
const redisClient = new redis.Client({
addrs: redis_addrs.split(',') || new Array('localhost:6379'), // in the form of 'host:port', separated by commas
password: redis_password,
});
const redisClient = new redis.Client('redis://localhost:6379');

export default async function () {
await redisClient.set('mykey', 10, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,8 @@ Decrements the number stored at `key` by `decrement`. If the key does not exist,
```javascript
import redis from 'k6/experimental/redis';

// Get the redis instance(s) address and password from the environment
const redis_addrs = __ENV.REDIS_ADDRS || '';
const redis_password = __ENV.REDIS_PASSWORD || '';

// Instantiate a new redis client
const redisClient = new redis.Client({
addrs: redis_addrs.split(',') || new Array('localhost:6379'), // in the form of 'host:port', separated by commas
password: redis_password,
});
const redisClient = new redis.Client('redis://localhost:6379');

export default async function () {
await redisClient.set('mykey', 10, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,8 @@ Removes the specified keys. A key is ignored if it does not exist.
```javascript
import redis from 'k6/experimental/redis';

// Get the redis instance(s) address and password from the environment
const redis_addrs = __ENV.REDIS_ADDRS || '';
const redis_password = __ENV.REDIS_PASSWORD || '';

// Instantiate a new redis client
const redisClient = new redis.Client({
addrs: redis_addrs.split(',') || new Array('localhost:6379'), // in the form of 'host:port', separated by commas
password: redis_password,
});
const redisClient = new redis.Client('redis://localhost:6379');

export default async function () {
await redisClient.set('mykey', 'myvalue', 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,8 @@ Returns the number of `key` arguments that exist. Note that if the same existing
```javascript
import redis from 'k6/experimental/redis';

// Get the redis instance(s) address and password from the environment
const redis_addrs = __ENV.REDIS_ADDRS || '';
const redis_password = __ENV.REDIS_PASSWORD || '';

// Instantiate a new redis client
const redisClient = new redis.Client({
addrs: redis_addrs.split(',') || new Array('localhost:6379'), // in the form of 'host:port', separated by commas
password: redis_password,
});
const redisClient = new redis.Client('redis://localhost:6379');

export default async function () {
let exists = await redisClient.exists('mykey');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,8 @@ Sets a timeout on key, after which the key will automatically be deleted. Note t
```javascript
import redis from 'k6/experimental/redis';

// Get the redis instance(s) address and password from the environment
const redis_addrs = __ENV.REDIS_ADDRS || '';
const redis_password = __ENV.REDIS_PASSWORD || '';

// Instantiate a new redis client
const redisClient = new redis.Client({
addrs: redis_addrs.split(',') || new Array('localhost:6379'), // in the form of 'host:port', separated by commas
password: redis_password,
});
const redisClient = new redis.Client('redis://localhost:6379');

export default async function () {
await redisClient.set('mykey', 'myvalue', 10);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,8 @@ Get the key's value.
```javascript
import redis from 'k6/experimental/redis';

// Get the redis instance(s) address and password from the environment
const redis_addrs = __ENV.REDIS_ADDRS || '';
const redis_password = __ENV.REDIS_PASSWORD || '';

// Instantiate a new redis client
const redisClient = new redis.Client({
addrs: redis_addrs.split(',') || new Array('localhost:6379'), // in the form of 'host:port', separated by commas
password: redis_password,
});
const redisClient = new redis.Client('redis://localhost:6379');

export default async function () {
await redisClient.set('mykey', 'myvalue', 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,8 @@ Get the value of `key` and delete the key. This functionality is similar to `get
```javascript
import redis from 'k6/experimental/redis';

// Get the redis instance(s) address and password from the environment
const redis_addrs = __ENV.REDIS_ADDRS || '';
const redis_password = __ENV.REDIS_PASSWORD || '';

// Instantiate a new redis client
const redisClient = new redis.Client({
addrs: redis_addrs.split(',') || new Array('localhost:6379'), // in the form of 'host:port', separated by commas
password: redis_password,
});
const redisClient = new redis.Client('redis://localhost:6379');

export default async function () {
await redisClient.set('mykey', 'oldvalue', 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,8 @@ Atomically sets `key` to `value` and returns the value previously stored at `key
```javascript
import redis from 'k6/experimental/redis';

// Get the redis instance(s) address and password from the environment
const redis_addrs = __ENV.REDIS_ADDRS || '';
const redis_password = __ENV.REDIS_PASSWORD || '';

// Instantiate a new redis client
const redisClient = new redis.Client({
addrs: redis_addrs.split(',') || new Array('localhost:6379'), // in the form of 'host:port', separated by commas
password: redis_password,
});
const redisClient = new redis.Client('redis://localhost:6379');

export default async function () {
await redisClient.set('mykey', 'oldvalue', 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,8 @@ Deletes the specified fields from the hash stored at `key`. The number of fields
```javascript
import redis from 'k6/experimental/redis';

// Get the redis instance(s) address and password from the environment
const redis_addrs = __ENV.REDIS_ADDRS || '';
const redis_password = __ENV.REDIS_PASSWORD || '';

// Instantiate a new redis client
const redisClient = new redis.Client({
addrs: redis_addrs.split(',') || new Array('localhost:6379'), // in the form of 'host:port', separated by commas
password: redis_password,
});
const redisClient = new redis.Client('redis://localhost:6379');

export default async function () {
await redisClient.hset('myhash', 'myfield', 'myvalue');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,8 @@ Returns the value associated with `field` in the hash stored at `key`.
```javascript
import redis from 'k6/experimental/redis';

// Get the redis instance(s) address and password from the environment
const redis_addrs = __ENV.REDIS_ADDRS || '';
const redis_password = __ENV.REDIS_PASSWORD || '';

// Instantiate a new redis client
const redisClient = new redis.Client({
addrs: redis_addrs.split(',') || new Array('localhost:6379'), // in the form of 'host:port', separated by commas
password: redis_password,
});
const redisClient = new redis.Client('redis://localhost:6379');

export default async function () {
await redisClient.hset('myhash', 'myfield', 'myvalue');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,8 @@ Returns all fields and values of the hash stored at `key`.
```javascript
import redis from 'k6/experimental/redis';

// Get the redis instance(s) address and password from the environment
const redis_addrs = __ENV.REDIS_ADDRS || '';
const redis_password = __ENV.REDIS_PASSWORD || '';

// Instantiate a new redis client
const redisClient = new redis.Client({
addrs: redis_addrs.split(',') || new Array('localhost:6379'), // in the form of 'host:port', separated by commas
password: redis_password,
});
const redisClient = new redis.Client('redis://localhost:6379');

export default async function () {
await redisClient.hset('myhash', 'myfield', 'myvalue');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,8 @@ Increments the integer value of `field` in the hash stored at `key` by `incremen
```javascript
import redis from 'k6/experimental/redis';

// Get the redis instance(s) address and password from the environment
const redis_addrs = __ENV.REDIS_ADDRS || '';
const redis_password = __ENV.REDIS_PASSWORD || '';

// Instantiate a new redis client
const redisClient = new redis.Client({
addrs: redis_addrs.split(',') || new Array('localhost:6379'), // in the form of 'host:port', separated by commas
password: redis_password,
});
const redisClient = new redis.Client('redis://localhost:6379');

export default async function () {
await redisClient.hset('myhash', 'myfield', 10);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,8 @@ Returns all fields of the hash stored at `key`.
```javascript
import redis from 'k6/experimental/redis';

// Get the redis instance(s) address and password from the environment
const redis_addrs = __ENV.REDIS_ADDRS || '';
const redis_password = __ENV.REDIS_PASSWORD || '';

// Instantiate a new redis client
const redisClient = new redis.Client({
addrs: redis_addrs.split(',') || new Array('localhost:6379'), // in the form of 'host:port', separated by commas
password: redis_password,
});
const redisClient = new redis.Client('redis://localhost:6379');

export default async function () {
await redisClient.hset('myhash', 'myfield', 'myvalue');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,8 @@ Returns the number of fields in the hash stored at `key`.
```javascript
import redis from 'k6/experimental/redis';

// Get the redis instance(s) address and password from the environment
const redis_addrs = __ENV.REDIS_ADDRS || '';
const redis_password = __ENV.REDIS_PASSWORD || '';

// Instantiate a new redis client
const redisClient = new redis.Client({
addrs: redis_addrs.split(',') || new Array('localhost:6379'), // in the form of 'host:port', separated by commas
password: redis_password,
});
const redisClient = new redis.Client('redis://localhost:6379');

export default async function () {
await redisClient.hset('myhash', 'myfield', 10);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,8 @@ Sets the specified field in the hash stored at `key` to `value`. If the `key` do
```javascript
import redis from 'k6/experimental/redis';

// Get the redis instance(s) address and password from the environment
const redis_addrs = __ENV.REDIS_ADDRS || '';
const redis_password = __ENV.REDIS_PASSWORD || '';

// Instantiate a new redis client
const redisClient = new redis.Client({
addrs: redis_addrs.split(',') || new Array('localhost:6379'), // in the form of 'host:port', separated by commas
password: redis_password,
});
const redisClient = new redis.Client('redis://localhost:6379');

export default async function () {
await redisClient.hset('myhash', 'myfield', 'myvalue');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,8 @@ Sets the specified field in the hash stored at `key` to `value`, only if `field`
```javascript
import redis from 'k6/experimental/redis';

// Get the redis instance(s) address and password from the environment
const redis_addrs = __ENV.REDIS_ADDRS || '';
const redis_password = __ENV.REDIS_PASSWORD || '';

// Instantiate a new redis client
const redisClient = new redis.Client({
addrs: redis_addrs.split(',') || new Array('localhost:6379'), // in the form of 'host:port', separated by commas
password: redis_password,
});
const redisClient = new redis.Client('redis://localhost:6379');

export default async function () {
await redisClient.hsetnx('myhash', 'myfield', 'myvalue');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,8 @@ Returns all values of the hash stored at `key`.
```javascript
import redis from 'k6/experimental/redis';

// Get the redis instance(s) address and password from the environment
const redis_addrs = __ENV.REDIS_ADDRS || '';
const redis_password = __ENV.REDIS_PASSWORD || '';

// Instantiate a new redis client
const redisClient = new redis.Client({
addrs: redis_addrs.split(',') || new Array('localhost:6379'), // in the form of 'host:port', separated by commas
password: redis_password,
});
const redisClient = new redis.Client('redis://localhost:6379');

export default async function () {
await redisClient.hset('myhash', 'myfield', 'myvalue');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,8 @@ Increments the number stored at `key` by one. If the key does not exist, it is s
```javascript
import redis from 'k6/experimental/redis';

// Get the redis instance(s) address and password from the environment
const redis_addrs = __ENV.REDIS_ADDRS || '';
const redis_password = __ENV.REDIS_PASSWORD || '';

// Instantiate a new redis client
const redisClient = new redis.Client({
addrs: redis_addrs.split(',') || new Array('localhost:6379'), // in the form of 'host:port', separated by commas
password: redis_password,
});
const redisClient = new redis.Client('redis://localhost:6379');

export default async function () {
await redisClient.set('mykey', 10, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,8 @@ Increments the number stored at `key` by `increment`. If the key does not exist,
```javascript
import redis from 'k6/experimental/redis';

// Get the redis instance(s) address and password from the environment
const redis_addrs = __ENV.REDIS_ADDRS || '';
const redis_password = __ENV.REDIS_PASSWORD || '';

// Instantiate a new redis client
const redisClient = new redis.Client({
addrs: redis_addrs.split(',') || new Array('localhost:6379'), // in the form of 'host:port', separated by commas
password: redis_password,
});
const redisClient = new redis.Client('redis://localhost:6379');

export default async function () {
await redisClient.set('mykey', 10, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,8 @@ Returns the specified element of the list stored at `key`. The index is zero-bas
```javascript
import redis from 'k6/experimental/redis';

// Get the redis instance(s) address and password from the environment
const redis_addrs = __ENV.REDIS_ADDRS || '';
const redis_password = __ENV.REDIS_PASSWORD || '';

// Instantiate a new redis client
const redisClient = new redis.Client({
addrs: redis_addrs.split(',') || new Array('localhost:6379'), // in the form of 'host:port', separated by commas
password: redis_password,
});
const redisClient = new redis.Client('redis://localhost:6379');

export default async function () {
await redisClient.rpush('mylist', 'first');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,8 @@ Returns the length of the list stored at `key`. If `key` does not exist, it is i
```javascript
import redis from 'k6/experimental/redis';

// Get the redis instance(s) address and password from the environment
const redis_addrs = __ENV.REDIS_ADDRS || '';
const redis_password = __ENV.REDIS_PASSWORD || '';

// Instantiate a new redis client
const redisClient = new redis.Client({
addrs: redis_addrs.split(',') || new Array('localhost:6379'), // in the form of 'host:port', separated by commas
password: redis_password,
});
const redisClient = new redis.Client('redis://localhost:6379');

export default function () {
redisClient
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,8 @@ Removes and returns the first element of the list stored at `key`.
```javascript
import redis from 'k6/experimental/redis';

// Get the redis instance(s) address and password from the environment
const redis_addrs = __ENV.REDIS_ADDRS || '';
const redis_password = __ENV.REDIS_PASSWORD || '';

// Instantiate a new redis client
const redisClient = new redis.Client({
addrs: redis_addrs.split(',') || new Array('localhost:6379'), // in the form of 'host:port', separated by commas
password: redis_password,
});
const redisClient = new redis.Client('redis://localhost:6379');

export default async function () {
await redisClient.lpush('mylist', 'first');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,8 @@ Inserts all the specified values at the head of the list stored at `key`. If `ke
```javascript
import redis from 'k6/experimental/redis';

// Get the redis instance(s) address and password from the environment
const redis_addrs = __ENV.REDIS_ADDRS || '';
const redis_password = __ENV.REDIS_PASSWORD || '';

// Instantiate a new redis client
const redisClient = new redis.Client({
addrs: redis_addrs.split(',') || new Array('localhost:6379'), // in the form of 'host:port', separated by commas
password: redis_password,
});
const redisClient = new redis.Client('redis://localhost:6379');

export default async function () {
await redisClient.lpush('mylist', 'first');
Expand Down
Loading

0 comments on commit 5f5c26f

Please sign in to comment.