I 100% support this idea. I know that there has been at least one time in the past where a "get keys" feature for our existing cache functionality was asked for. I don't recall the specific use case but I think I filed a feature request at the time.
Original Message:
Sent: May 03, 2023 12:15 PM
From: Joseph Fry
Subject: [Experimental Feature] Distributed Key Value Storage
Ben, I wouldn't say that the primary purpose is to delete keys, that was just an example.
One customer hoped to use a cache to gather transaction metrics for a service. Every request would add the transaction time and username as the key/data to a cache with a 24 hour expiration. A separate service would have returned a web page showing the last day's worth of transactions by looping over the keys in the cache. Unfortunately without being able to list the keys, there was no way to use the cache this way because you need to know the key to retrieve the value; so now they have to log each transaction to a database.
I totally appreciate that there are technical concerns associated with my idea.
Likely the easiest way to implement this would be to create a "get keys" assertion that accepts a cache id (check a box for the distributed key store), a 'count', a 'skip past key', and a 'target variable' field. The count would be used to limit the number of keys returned. "Skip past key" would allow you to skip past the last key you previously consumed (assuming that the key store/cache are FIFO) to allow you to do batch operations. It would return a multivalued context variable containing the keys that the customer can then use existing assertions such as "run assertions for each item" against.
Original Message:
Sent: May 03, 2023 10:31 AM
From: Ben Urbanski
Subject: [Experimental Feature] Distributed Key Value Storage
Thanks, Joe. Great feedback. We haven't considered enhancing the lookup assertion or adding a new assertion to get all keys in the store, but we will now. However, if the primary use case for that would be to delete all keys, wouldn't it be better to just provide a delete all keys feature? We can still consider getting all keys, but I do worry about scenarios where there are possibly millions of keys.
------------------------------
Ben Urbanski
Product Manager, API Gateway
Layer7 API Management
Original Message:
Sent: Apr 28, 2023 11:47 AM
From: Joseph Fry
Subject: [Experimental Feature] Distributed Key Value Storage
Ben,
Great feature. I am curious if there has been any thought given to being able to list all of the keys in the store? I realize that this is not really the intent of a key/value store, but it can be useful.
For example, you might store a username/sessionId key value pair, and want to provide the ability to logout all users (purge their session keys so they are forced to reauthenticate). This is virtually impossible if you cannot get a list of the keys in the store.
I have run into similar scenarios where the inability to list the keys forced us to use an external database call when the cache would have been much more performant.