question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Redis: delete and write data

See original GitHub issue

We want to use a DSL supporting EL to delete (DEL, SREM) and write data (SADD) to Redis, similar to a Redis feeder. The motivation to use the Redis feeder this way is that we often use Redis to write, update and read OAuth tokens in scripts. Would this violate the feeders concept? It is planned to commit this? And will you be ready to accept this implementation if we do it by adding redis command based on gatling-redis library?

Example DSL:

class RedisScenario {
 val redisPool = new RedisClientPool("localhost", 6379)
 def myRedisSADDFeeder(value: String, values: String*) = redisFeeder(redisPool, "key", value, values).SADD
 def myRedisDELFeeder(key: String, keys: String*) = redisFeeder(redisPool, key, keys).DEL
 def myRedisSREMFeeder(value: String, values: String*) = redisFeeder(redisPool, "key", value, values).SREM
  
 val getParameter: HttpRequestBuilder = http("GET PARAMETER")
  .get("/")
  .check(regex("""SPDX-License-Identifier: (\w.+)""").saveAs("value_1"))
  .check(regex("""Copyright (\w.+)""").saveAs("value_2"))

 val redisGetTokenScenario: ScenarioBuilder = scenario("Redis scenario")
  .exec(getParameter)
  .feed(myRedisSADDFeeder("${value_1}", "${value_2}"))
  .feed(myRedisDELFeeder("key", "key1"))
  .feed(myRedisSREMFeeder("${value_1}", "${value_2}"))

}

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:5
  • Comments:12 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
slandellecommented, Jun 20, 2022

Several things.

Using Feeder/feed for writing

That’s a big no.

First, Feeder and feed are only meant for pulling records and copy them into Sessions. They are not meant to remove or modify data, all the more from an external system, and don’t take any parameter. So something like requested doesn’t belong there:

  .feed(myRedisSADDFeeder("${value_1}", "${value_2}"))
  .feed(myRedisDELFeeder("key", "key1"))
  .feed(myRedisSREMFeeder("${value_1}", "${value_2}"))

So now quick win by just add some more operations on RedisFeederBuilder.

Feeder currently only supports a blocking API

Feeder was designed to work with in-memory data: CSV and JSON files fully loaded in memory on boot and in-memory random data generator. Those are 100% fine with the blocking API.

Later, I also introduced the lazy feeders able to deal with humongous files. The files are on the local filesystem and the CSV parser is pretty fast, so it’s mostly fine for most use cases.

Now, there’s the case of the JDBC and REDIS feeders that perform a blocking network call on each Iterator.next(). I wouldn’t use those for high throughput use cases. In order for them to be efficient, we’d most likely need new implementations based on an async API, probably respectively on R2DBC and Lettuce. We’d probably have to move those into optional modules because of the extra dependencies.

exec(function) is a blocking API

It was designed to let users edit Session.

  • It’s sometimes diverted to push or pull data from a global shared in-memory store, which is fine.
  • It’s also sometimes diverted to write some data on disk, which can be an issue if your disk is slow or subject to hiccups.
  • It’s also sometimes diverted to perform blocking network IO and this is plain wrong. You would have to implement a proper Action.
0reactions
shoaib42commented, Jun 20, 2022

@slandelle Yikes, I didn’t think about that. I think what @Dmitriy-Smol has requested, is similar to the RPOPLPUSH that I did. Wouldn’t it be a similar issue of blocking call with the feeder, if DEL SADD SREM were to be added? (Adding these would be pretty straight forward)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Delete Everything in Redis - Baeldung
There are two major commands to delete the keys present in Redis: FLUSHDB and FLUSHALL. We can use the Redis CLI to execute...
Read more >
DEL | Redis
When a key to remove holds a value other than a string, the individual complexity for this key is O(M) where M is...
Read more >
Redis Delete Key - Linux Hint
Deleting a key in Redis is as simple as creating one. We use the DEL command followed by the name of the key...
Read more >
How to Delete All Data in Redis | Tutorial by Chartio
Redis is a NoSQL database that runs almost entirely in memory. One capability of Redis is deleting everything in your entire database or...
Read more >
Set and delete or just overwrite? - redis - Stack Overflow
The set command overwrites if string data already exists at the key specified. So, in a way there is a delete and write...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found