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
/*
* Copyright 2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@mp911de
mp911de / Standalone.java
Created October 30, 2017 20:35
Create Redis Connections with pooling
/*
* Copyright 2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@mp911de
mp911de / CommandHandlerBuffers.java
Created September 25, 2017 13:37
Accessing CommandHandler buffers in Lettuce 4
RedisClient redisClient = RedisClient.create(RedisURI.Builder.redis("localhost", 6379).build());
StatefulRedisConnection<String, String> redis = redisClient.connect();
RedisChannelHandler<String, String> channelHandler = (RedisChannelHandler) redis;
CommandHandler<String, String> commandHandler = (CommandHandler) channelHandler.getChannelWriter();
Collection<RedisCommand<String, String, ?>> disconnectedBuffer = null; // reflective access to commandHandler.disconnectedBuffer
Collection<RedisCommand<String, String, ?>> commandBuffer = null; // reflective access to commandHandler.commandBuffer
package com.example.demo9;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class Demo9Application implements CommandLineRunner {
/*
* Copyright 2015-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
import com.lambdaworks.redis.RedisClient;
import com.lambdaworks.redis.ScriptOutputType;
import com.lambdaworks.redis.api.StatefulRedisConnection;
import com.lambdaworks.redis.codec.ByteArrayCodec;
/**
* @author Mark Paluch
*/
public class EvalWithByteArrayCodec {
import java.nio.ByteBuffer;
import com.lambdaworks.redis.codec.ByteArrayCodec;
import com.lambdaworks.redis.codec.RedisCodec;
import com.lambdaworks.redis.codec.StringCodec;
/**
* @author Mark Paluch
*/
class StringByteRedisCodec implements RedisCodec<String, byte[]> {
@mp911de
mp911de / CassandraPlaygroundApplication.java
Created March 21, 2017 10:12
Working example for DATACASS-414
package com.example;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class CassandraPlaygroundApplication {
public static void main(String[] args) {
SpringApplication.run(CassandraPlaygroundApplication.class, args);
import io.netty.handler.codec.http.HttpHeaderNames;
import reactor.core.publisher.Hooks;
import reactor.core.publisher.Mono;
import reactor.ipc.netty.NettyContext;
import reactor.ipc.netty.http.server.HttpServer;
import java.io.IOException;
import java.nio.file.FileSystem;
import java.nio.file.FileSystems;
import java.nio.file.Path;
@mp911de
mp911de / CassandraZoneddatetimeApplication.java
Created February 28, 2017 17:08
Using ZonedDateTime with Spring Data Cassandra stored in tuples.
package com.example;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.RequiredArgsConstructor;
import java.time.ZonedDateTime;
import java.util.List;