当前位置:网站首页>Flink SQL realizes reading and writing redis and dynamically generates hset key
Flink SQL realizes reading and writing redis and dynamically generates hset key
2022-07-07 05:34:00 【HD0do】
In the official offering flink-connect-redis It doesn't work Flink SQL Read and write in a different way redis. If you want to achieve Flink sql Read and write in a different way redis You need to implement the corresponding code yourself , Fortunately GitHub There is already a corresponding open source implementation , We only need to use the corresponding reference .
pom rely on :
<dependency>
<groupId>io.github.jeff-zou</groupId>
<artifactId>flink-connector-redis</artifactId>
<version>1.0.11</version>
</dependency>By importing jar, Can achieve Flink sql Reading and writing redis :
First create Flink CDC A watch of :
CREATE TABLE memberCDC(
`member_id` bigint,
mobile string,
`tenant_id` string ,
gender int ,
proctime as procTime(),
PRIMARY KEY(member_id) NOT ENFORCED
) WITH (
'connector' = 'mysql-cdc',
'hostname' = '10.50.20.181',
'port' = '330806',
'username' = 'reGaYTkly',
'password' = '40IGOJHFDlloBE6',
'database-name' = 'member_db',
'table-name' = 'm_member_tenant',
'scan.startup.mode'='latest-offset',
'debezium.skipped.operations'='d'
)Flink SQL write in redis( With Hset For example, data type ):
CREATE TABLE memberRedis (
`member_id` bigint,
mobile string,
`tenant_id` string,
gender int
) WITH (
'connector' = 'redis',
'host' = '10.180.80.89',
'port' = '300079',
'password' = 'big88dajjggta34',
'redis-mode' = 'single',
'command'='hset'
)
inserter into memberRedis
select
member_id,
mobile,
tenant_id,
gender
from memberCDChere member_id amount to Hset Of additionalKey mobile amount to key, And this can be done through SQL The dynamic splicing of statements is needed key Format . It is equivalent to supporting dynamic generation of what you need key.
Flink SQL Read redis( With Hset For example, data type ):
Read redis Data in , It is generally used as a dimension Association :
CREATE TABLE memberSourceRedis (
`member_id` bigint,
mobile string,
`tenant_id` string,
gender int
) WITH (
'connector' = 'redis',
'host' = '10.110.60.5',
'port' = '30479',
'password' = 'daffdag1234',
'redis-mode' = 'single',
'command'='hget',
'maxIdle'='2',
'minIdle'='1',
'lookup.cache.max-rows'='10',
'lookup.cache.ttl'='10',
'lookup.max-retries'='3'
)insert into memberRedis
select
t2.member_id,
t2.mobile,
t2.tenant_id,
t1.gender
from memberCDC t1
left join memberSourceRedis for system_time as of t1.proctime as t2 on
t1.member_id = t2.member_id and t1.mobile = t2.mobileSimilar reading , here member_id amount to Hset Of additionalKey mobile amount to key, Here you can go through SQL Statement dynamic splicing generation key, incoming key It's actually memberCDC The data value of the associated field in .
Connect redis parameter list :


summary :
Above Flink SQL Reading and writing redis about hset Data types support writing and reading values of a field , Multiple field writes will be filtered by default .
If you want to support writing and reading of multiple fields , The dependent code needs to be modified , When writing, multiple fields are encapsulated as JSONString write in Redis, When reading, the JSON Data is passed through catalog Map to values corresponding to multiple fields .
Subsequent articles will also introduce how to modify the source code , compile jar Package to support multiple fields Flink SQL Read and write redis. If you need it, you can also use the following link to realize the corresponding flink sql Reading and writing Redis Special business needs . Feel useful and welcome to pay attention Dida official account ~~
In this paper, the reference GitHub Open source projects for :https://github.com/jeff-zou/flink-connector-redis
边栏推荐
- 实现网页内容可编辑
- 在米家、欧瑞博、苹果HomeKit趋势下,智汀如何从中脱颖而出?
- 一条 update 语句的生命经历
- 4. Object mapping Mapster
- 做自媒体视频剪辑,专业的人会怎么寻找背景音乐素材?
- How does redis implement multiple zones?
- Let f (x) = Σ x^n/n^2, prove that f (x) + F (1-x) + lnxln (1-x) = Σ 1/n^2
- 《5》 Table
- JHOK-ZBL1漏电继电器
- Under the trend of Micah, orebo and apple homekit, how does zhiting stand out?
猜你喜欢

Pytest testing framework -- data driven
![[JS component] custom select](/img/9d/f7f15ec21763c40b9bb6a053d90ee4.jpg)
[JS component] custom select

4. 对象映射 - Mapping.Mapster

京东商品详情页API接口、京东商品销量API接口、京东商品列表API接口、京东APP详情API接口、京东详情API接口,京东SKU信息接口

Cve-2021-3156 vulnerability recurrence notes

照片选择器CollectionView

Zhang Ping'an: accelerate cloud digital innovation and jointly build an industrial smart ecosystem

DOM-节点对象+时间节点 综合案例

The year of the tiger is coming. Come and make a wish. I heard that the wish will come true

Leetcode 1189 maximum number of "balloons" [map] the leetcode road of heroding
随机推荐
K6el-100 leakage relay
K6EL-100漏电继电器
Zhang Ping'an: accelerate cloud digital innovation and jointly build an industrial smart ecosystem
How digitalization affects workflow automation
Design, configuration and points for attention of network arbitrary source multicast (ASM) simulation using OPNET
Taobao commodity details page API interface, Taobao commodity list API interface, Taobao commodity sales API interface, Taobao app details API interface, Taobao details API interface
Mapbox Chinese map address
Tablayout modification of customized tab title does not take effect
Disk monitoring related commands
Intelligent annotation scheme of entity recognition based on hugging Face Pre training model: generate doccano request JSON format
设f(x)=∑x^n/n^2,证明f(x)+f(1-x)+lnxln(1-x)=∑1/n^2
How does mapbox switch markup languages?
Make web content editable
漏电继电器JOLX-GS62零序孔径Φ100
LabVIEW is opening a new reference, indicating that the memory is full
Creation and use of thread pool
JD commodity details page API interface, JD commodity sales API interface, JD commodity list API interface, JD app details API interface, JD details API interface, JD SKU information interface
Record a pressure measurement experience summary
nodejs获取客户端ip
JVM (19) -- bytecode and class loading (4) -- talk about class loader again