public class RedisDataSource<T> extends AbstractDataSource<String,T>
A read-only DataSource with Redis backend.
The data source first loads initial rules from a Redis String during initialization. Then the data source subscribe from specific channel. When new rules is published to the channel, the data source will observe the change in realtime and update to memory.
Note that for consistency, users should publish the value and save the value to the ruleKey simultaneously like this (using Redis transaction):
MULTI SET ruleKey value PUBLISH channel value EXEC
parser, property| 构造器和说明 |
|---|
RedisDataSource(RedisConnectionConfig connectionConfig,
String ruleKey,
String channel,
Converter<String,T> parser)
Constructor of
RedisDataSource. |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
close() |
String |
readSource() |
getProperty, loadConfig, loadConfigpublic RedisDataSource(RedisConnectionConfig connectionConfig, String ruleKey, String channel, Converter<String,T> parser)
RedisDataSource.connectionConfig - Redis connection configruleKey - data key in Redischannel - channel to subscribe in Redisparser - customized data parser, cannot be emptypublic String readSource()
public void close()
Copyright © 2022 Alibaba Group. All rights reserved.