KeysReader
从数据库中获取键及其值。
Redis 堆栈 |
---|
根据存储在 Redis 数据库中的键和值创建记录。
注意:
目前仅支持 string 和 hash 数据类型。对于其他数据类型,它只会提取键名称。构造 函数
您可以使用这些构造函数之一来创建新的KeysReader
对象:
public KeysReader()
public KeysReader(String pattern)
public KeysReader(String prefix, boolean readValues)
public KeysReader(String pattern, boolean noScan, boolean readValues)
public KeysReader(String prefix,
boolean readValues,
String[] eventTypes,
String[] keyTypes)
public KeysReader(String pattern,
boolean noScan,
boolean readValues,
String[] eventTypes,
String[] keyTypes)
Parameters
Name
Type
Default value
Description
commands
array of strings
null
The commands that this reader is registered on
eventTypes
array of strings
null
The event types to register on (usually the command name)
keyTypes
array of strings
null
The key types to register on
noScan
boolean
false
Whether or not to scan the key space or just read the pattern as is
pattern/prefix
string
"*" (match all keys)
The reader will get all keys that match this pattern
readValues
boolean
true
Whether or not to read the keys' values
Output records
Creates a KeysReaderRecord
for each matching key in the database.
Name
Type
Description
key
string
The name of the key
type
long
The core Redis type: 'string', 'hash', 'list', 'set', 'zset', or 'stream'
event
string
The event that triggered the execution (null if using the run function)
stringVal
string
The key's value for string data types
hashVal
Map<String,String>
The key's value for hash data types
listVal
List
The key's value for list data types
setVal
Set
The key's value for set data types
Examples
Here's a basic example of a KeysReader
that creates records for all keys in the database:
KeysReader reader = new KeysReader();
In the following example, the KeysReader
creates records for all keys in the database that start with "person:". When registered, it only runs for hashes after HSET
and DEL
events occur.
String[] eventTypes = {"HSET", "DEL"};
String[] keyTypes = {"HASH"};
KeysReader reader = new KeysReader("person:*", false, true, eventTypes, keyTypes);
On this page