Skip to content

Instantly share code, notes, and snippets.

View mp911de's full-sized avatar
🚑
I may be slow to respond…

Mark Paluch mp911de

🚑
I may be slow to respond…
View GitHub Profile
@mp911de
mp911de / RedisMultiFutureSubscription.java
Last active August 29, 2015 14:21
Using RxJava with lettuce (timeout and event executor should be adopted to suit your needs). Thx to @vleushin
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Vector;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Supplier;
@mp911de
mp911de / MyEventPayload.java
Created June 18, 2015 06:10
Prioritized Event Observers with CDI 2.0 (EDR1)
public class MyEventPayload {
}
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x0000000106a0ae31, pid=48915, tid=4867
#
# JRE version: Java(TM) SE Runtime Environment (8.0_05-b13) (build 1.8.0_05-b13)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.5-b02 mixed mode bsd-amd64 compressed oops)
# Problematic frame:
# V [libjvm.dylib+0x40ae31]
#
@mp911de
mp911de / Experiment.java
Created July 10, 2015 07:34
fireAsync with CDI 2.0-EDR1
public class Experiment {
}
@mp911de
mp911de / RedisExample.java
Created July 12, 2015 15:20
Example for loading/storing a string-based HttpSession from/to Redis using CDI
package biz.paluch.redis.example;
import java.util.Enumeration;
import java.util.Map;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.inject.Inject;
import javax.servlet.http.HttpSession;
package com.lambdaworks.redis;
import static com.google.code.tempusfugit.temporal.Duration.seconds;
import static com.google.code.tempusfugit.temporal.WaitFor.waitOrTimeout;
import static com.lambdaworks.redis.ScriptOutputType.STATUS;
import static org.assertj.core.api.Assertions.assertThat;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
@mp911de
mp911de / Util.java
Created July 21, 2015 10:18
Telling definitely you don't like instances of Util
public class Util {
private Util() {
throw new UnsupportedOperationException();
}
}
@mp911de
mp911de / SnappyCompressor.java
Last active August 30, 2015 18:56
Java Snappy compressor wrapper for a lettuce codec to store snappy-compressed values within Redis
import static com.google.common.base.Preconditions.checkArgument;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import org.xerial.snappy.SnappyInputStream;
import org.xerial.snappy.SnappyOutputStream;
import com.google.common.io.ByteStreams;
@mp911de
mp911de / JedisCluster.java
Last active November 27, 2015 16:50
Connecting a Redis Cluster
import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.JedisCluster;
import java.util.HashSet;
import java.util.Set;
public class JedisCluster {
public static void main(String[] args) {
Set<HostAndPort> connectionPoints = new HashSet<HostAndPort>();
@mp911de
mp911de / MyExtendedRedisClient.java
Created August 11, 2015 06:11
Implementing "cancel commands while disconnected" for https://github.com/mp911de/lettuce/issues/115
import javax.enterprise.inject.Alternative;
import com.lambdaworks.redis.RedisClient;
import com.lambdaworks.redis.RedisURI;
import com.lambdaworks.redis.StatefulRedisConnectionImpl;
import com.lambdaworks.redis.codec.RedisCodec;
import com.lambdaworks.redis.protocol.CommandHandler;
import com.lambdaworks.redis.pubsub.PubSubCommandHandler;
import com.lambdaworks.redis.pubsub.StatefulRedisPubSubConnectionImpl;