-
Notifications
You must be signed in to change notification settings - Fork 949
Streaming API
Redis can contain a huge set of data. Collections can burst your memory, when the amount of data is too massive for your heap.
Lettuce can return your collection data either as List/Set/Map or can push the data on StreamingChannel
interfaces.
StreamingChannel
s are similar to callback methods. Every method, which can return bulk data (except transactions/multi and some config methods) specifies beside a regular method with a collection return class also method which accepts a StreamingChannel
. Lettuce interacts with a StreamingChannel
as the data arrives so data can be processed while the command is running and is not yet completed.
There are 4 StreamingChannels accepting different data types:
The result of the steaming methods is the count of keys/values/key-value pairs as long
value.
Note
|
Don’t issue blocking calls (includes synchronous API calls to Lettuce) from inside of callbacks such as the streaming API as this would block the EventLoop. If you need to fetch data from Redis from inside a StreamingChannel callback, please use the asynchronous API or use the reactive API directly.
|
HGETALL
Long count = redis.hgetall(new KeyValueStreamingChannel<String, String>()
{
@Override
public void onKeyValue(String key, String value)
{
...
}
}, key);
Streaming happens real-time to the redis responses. The method call (future) completes after the last call to the StreamingChannel.
redis.lpush("key", "one")
redis.lpush("key", "two")
redis.lpush("key", "three")
Long count = redis.lrange(new ValueStreamingChannel<String, String>()
{
@Override
public void onValue(String value)
{
System.out.println("Value: " + value);
}
}, "key", 0, -1);
System.out.println("Count: " + count);
will produce the following output:
Value: one Value: two Value: three Count: 3
This wiki and the README document contains a lot of information, please take your time and read these instructions carefully.
If you run into any trouble, you may start with getting started.
We provide detailed changes for each Lettuce release.
Be sure to read the CONTRIBUTING guidelines before reporting a new Lettuce issue or open a pull request.
If you have any questions about the Lettuce usage or want to share some information with the community, please go to one of the following places:
- GitHub Discussions
-
for chatting
More resources:
- Javadoc
- Build status: Travis CI
- All versions: Maven Central
- Snapshots: Sonatype OSS Repository
Intro
Getting started
- Getting started
- Redis URI and connection details
- Basic usage
- Asynchronous API
- Reactive API
- Publish/Subscribe
- Transactions/Multi
- Scripting and Functions
- Redis Command Interfaces
- FAQ
HA and Sharding
Advanced usage
- Configuring Client resources
- Client Options
- Dynamic Command Interfaces
- SSL Connections
- Native Transports
- Unix Domain Sockets
- Streaming API
- Events
- Command Latency Metrics
- Tracing
- Stateful Connections
- Pipelining/Flushing
- Connection Pooling
- Graal Native Image
- Custom commands
Integration and Extension
Internals