12 Ağustos 2021 Perşembe

Redis Stream Veri Yapısı - Persistent Pub/Sub

Giriş
Stream işleri için JedisPool Sınıfı kullanılır. Understanding Redis Streams yazısına bakılabilir

Açıklaması şöyle.
Redis, meanwhile, recently announced its new data structure, called " Streams," for managing streaming data. Redis Streams offers asynchronous communication between producers and consumers, with additional features such as persistence, look-back queries, and scale-out options — similar to Apache Kafka. In essence, with Streams, Redis provides a light, fast, easy-to-manage streaming database that benefits data engineers.
Persistency vardır. Açıklaması şöyle
Introduced in Redis 5.0, Redis Streams provides the best of Pub/Sub and Lists along with reliable messaging, durability for messages replay, Consumer Groups for load balancing, Pending Entry List for monitoring and much more! What makes it different is that fact it is a append-only log data structure. In a nutshell, producers can add records (using XADD), consumers can subscribe to new items arriving to the stream (with XREAD). It supports range queries (XRANGE etc.) and thanks to consumer groups, a group of apps can distribute the processing load (XREADGROUP) and its possible to monitor its state (XPENDING etc).
Consumer Group'lar şeklen şöyle
Bir başka şekil şöyle. Bu kullanımla aynı Kafka'ya benziyor.

Açıklaması şöyle
Redis Streams messages are string key/values in Java.

Read entries
Açıklaması şöyle
XRANGE
returns the stream entries matching a given range of IDs (the - and + special IDs mean respectively the minimum ID possible and the maximum ID possible inside a stream)
XREVRANGE
is exactly like XRANGE, but with the difference of returning the entries in reverse order (use the end ID first and the start ID later)
XREAD
reads data from one or multiple streams, only returning entries with an ID greater than the last received ID reported by the caller.
XREADGROUP
is a special version of the XREAD command with support for consumer groups. You can create groups of clients that consume different parts of the messages arriving in a given stream
Write Entries
XADD : Yeni veri ekler


Manage Redis Streams
Açıklaması şöyle
XACK
removes one or multiple messages from the Pending Entries List (PEL) of a stream consumer group.
XGROUP
is used to manage the consumer groups associated with a Redis stream.
XPENDING
is the used to inspect the list of pending messages to observe and understand what is happening with a streams consumer groups.
XCLAIM
is used to acquire the ownership of the message and continue processing.
XAUTOCLIAM
transfers ownership of pending stream entries that match the specified criteria. Conceptually, XAUTOCLAIM is equivalent to calling XPENDING and then XCLAIM
Delete
Açıklaması şöyle
XDEL
removes the specified entries from a stream, and returns the number of entries deleted, that may be different from the number of IDs passed to the command in case certain IDs do not exist.
XTRIM
trims the stream by evicting older entries (entries with lower IDs) if needed.
Örnek
Stream kullanmak için bir örnek burada.

Hiç yorum yok:

Yorum Gönder