Skip to content

shahrivari/redipper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Redipper

Build Status

Goals / Background

Build Status Coverage Status

Redipper is a simple redis wrapper for Lettuce which makes it easier to use. The core features are:

  • Definition of spaces over redis which gives a table-like feel over db.
  • Generic collection API like Redisson.
  • Automatic serialization of objects.
  • Various encoders for compression and encryption.

Get started

1.Add JitPack repository to your project:

pom.xml file:
<repository>
    <id>jitpack.io</id>
    <url>https://jitpack.io</url>
</repository>

2. Add dependency

pom.xml file:
<dependency>
    <groupId>com.github.shahrivari</groupId>
    <artifactId>redipper</artifactId>
    <version>v1.28</version>
</dependency>

Usage

Create object of any classes on your demand.

val personCache = RedisMap.newBuilder<Person>(redisConfig, "person")
            .withTtl(10, TimeUnit.SECONDS)
            .withLoader { getPerson() }
            .build()

personCache.set(person.id.toString(), personInstance)

personCache.get(person.id.toString())            

If you have specific serializer, you can pass it to redisWrapper as described below:

val studentCache = RedisMap.newBuilder<Student>(redisConfig, "student")
            .withTtl(10, TimeUnit.SECONDS)
            .withLoader { getStudent() }
            .withSerializer(StudentSerializer.build())
            .build()

studentCache.set(student.id.toString(), studentInstance)

studentCache.get(student.id.toString())            

Most of this code is written by Mohammad Hossein Liaghat and Mohammad Amin Badiezadegan.