Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
😼

Mark Paluch mp911de

:octocat:
😼
View GitHub Profile
@mp911de
mp911de / RedisMultiFutureSubscription.java
Last active Aug 29, 2015
Using RxJava with lettuce (timeout and event executor should be adopted to suit your needs). Thx to @vleushin
View RedisMultiFutureSubscription.java
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 Jun 18, 2015
Prioritized Event Observers with CDI 2.0 (EDR1)
View MyEventPayload.java
public class MyEventPayload {
}
View hs_err_pid48915.log
#
# 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 Jul 10, 2015
fireAsync with CDI 2.0-EDR1
View Experiment.java
public class Experiment {
}
@mp911de
mp911de / RedisExample.java
Created Jul 12, 2015
Example for loading/storing a string-based HttpSession from/to Redis using CDI
View RedisExample.java
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;
View ClientTest.java
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 Jul 21, 2015
Telling definitely you don't like instances of Util
View Util.java
public class Util {
private Util() {
throw new UnsupportedOperationException();
}
}
@mp911de
mp911de / SnappyCompressor.java
Last active Aug 30, 2015
Java Snappy compressor wrapper for a lettuce codec to store snappy-compressed values within Redis
View SnappyCompressor.java
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 Nov 27, 2015
Connecting a Redis Cluster
View JedisCluster.java
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>();
View MyExtendedRedisClient.java
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;