Search code examples
javaredislocalamazon-elasticache

Redis for Local Testing using Java Jedis Client without a REDIS Server


I am pretty new to redis cache and trying to figure out a way to test my changes (Repositories) for redistribution locally. The idea is I do not have a redis server running locally, I do have it in my dev env but what I intend to have is the ability to run my redis code locally and when I save the data it gets saved to some in-memory db or somewhere else instead of redis DB which would let me test my logical changes. The issue is since I do not have redis locally (also it is not possible for me to have it on my local machine) my repository code doesn't work.

eg :

// Functional Logic // userRepository.save(data) --> This would not work because repository itself isn't built as redis configurations don't work

I tried googling but I only find how to use redis for integration test . What I'm looking for is something similar to H2 DB that stores data locally.


Solution

  • There are a couple of options that you can try to run Redis Server locally:

    1. Install Docker and run the Redis pre-built image obtained from DockerHub
    2. If you have MacOS or Linux based local machine, you can easily install Redis Server distribution on it.

    Also, you can have a embedded Redis server running inside your main application similar to H2 DB that you are referring to. Please follow the link https://www.baeldung.com/spring-embedded-redis for the details about how to configure and customize embedded Redis server as per your local testing environment.