Code Monkey home page Code Monkey logo

lettuce's Introduction

lettuce - A scalable Java Redis client

  Lettuce is a scalable thread-safe Redis client providing both synchronous and
  asyncronous connections. Multiple threads may share one connection provided
  they avoid blocking and transactional operations such as BLPOP, and MULTI/EXEC.
  Multiple connections are efficiently managed by the excellent netty NIO
  framework.

  This version of lettuce has been tested against redis 2.6.12

  Join the lambdaWorks-OSS Google Group to discuss this project:

    http://groups.google.com/group/lambdaworks-oss
    [email protected]

Basic Usage

  RedisClient client = new RedisClient("localhost")
  RedisConnection<String, String> connection = client.connect()
  String value = connection.get("key")

  Each redis command is implemented by one or more methods with names identical
  to the lowercase redis command name. Complex commands with multiple modifiers
  that change the result type include the CamelCased modifier as part of the
  command name, e.g. zrangebyscore and zrangebyscoreWithScores.

  Redis connections are designed to be long-lived, and if the connection is lost
  will reconnect until close() is called. Pending commands that have not timed
  out will be (re)sent after successful reconnection.

  All connections inherit a default timeout from their RedisClient and
  and will throw a RedisException when non-blocking commands fail to return a
  result before the timeout expires. The timeout defaults to 60 seconds and
  may be changed in the RedisClient or for each individual connection.

Asynchronous Connections

  RedisAsyncConnection<String, String> async = client.connectAsync()
  Future<String> set = async.set("key", "value")
  Future<String> get = async.get("key")

  async.awaitAll(set, get) == true

  set.get() == "OK"
  get.get() == "value"

Pub/Sub

  RedisPubSubConnection<String, String> connection = client.connectPubSub()
  connection.addListener(new RedisPubSubListener<String, String>() { ... })
  connection.subscribe("channel")

Codecs

  Lettuce supports pluggable codecs responsible for encoding and decoding keys
  and values. The default codec supports UTF-8 encoded String keys and values.

  Each connection may have its own codec passed to the extended
  RedisClient.connect methods:

  RedisConnection<K, V> connect(RedisCodec<K, V> codec)
  RedisAsyncConnection<K, V> connectAsync(RedisCodec<K, V> codec)
  RedisPubSubConnection<K, V> connectPubSub(RedisCodec<K, V> codec)

  For pub/sub connections channel names and patterns are treated as keys,
  messages are treated as values.

Maven Artifacts

  Releases of lettuce are available in the maven central repository.

  <dependency>
    <groupId>com.lambdaworks</groupId>
    <artifactId>lettuce</artifactId>
    <version>2.3.3</version>
  </dependency>

lettuce's People

Contributors

wg avatar

Watchers

James Cloos avatar Jeff avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.