dragonfly icon indicating copy to clipboard operation
dragonfly copied to clipboard

Java Integration

Open aabolfazl opened this issue 1 year ago • 2 comments

Java Integration. Hey Dragonfly owners, would you mind writing a client for this library in Java? or will you support this implementation if someone like to do it?

Use in JVM-based server framework As you know Java and JVM-based languages have many powerful web frameworks, I think it will be helpful if we can provide a way to use this library in these frameworks with a standalone Client like spring-data-redis.

aabolfazl avatar Jun 30 '23 09:06 aabolfazl

Hi @aabolfazl and thank you for opening an issue.

Dragonfly is redis API compatible (we don't yet support all the currently existing commands, but most of them should be available) which means that third party client libraries should work outside of the box.

Did you have any issue using Dragonfly with any of the already existing client libraries?

kostasrim avatar Jun 30 '23 10:06 kostasrim

@kostasrim

From what you mentioned above, I think there will be no problem if it is integrated to the redis client(like spring-data-redis) api.

i will actually test it after building on AWS. If there is a problem in the future, I will register the issue.

brewagebear avatar Jul 04 '23 17:07 brewagebear

@aabolfazl

I am also a Java developer, so I became interested in the question you wrote. And i did a brief test with reference to what @kostasrim said above.

repository : https://github.com/brewagebear/counter-api

sample code

  • CacheService.java
@Service
public class CacheService {

    @CachePut(cacheNames = "namespace", key="#namespace")
    public int updateNamespace(String namespace, Map<String, String> data) {
        return 1;
    }
}
  • CacheController
@RestController
@RequestMapping("/api")
public class CacheController {

    private final CacheService cacheService;

    public CounterController(CacheService cacheService) {
        this.cacheService = cacheService;
    }
    
    @GetMapping("/test")
    public void cache() {
        cacheService.updateNamespace("test", Map.of("test", "1"));
    }
}

result

Screenshot 2023-07-06 at 17 57 16 Screenshot 2023-07-06 at 17 59 31

It's a very simple test, so I think I need to check if other APIs are compatible well, but if there's a problem with this part, I'll check and create an issue.

First of all, i confirmed that it works normally in a simple test.

brewagebear avatar Jul 06 '23 08:07 brewagebear

To conclude - we support Redis client libraries out of the box. Feel free to open a specific issue if you stumble upon any problem.

romange avatar Jul 13 '23 07:07 romange