Skip to content

Commit

Permalink
Implement local redis interface
Browse files Browse the repository at this point in the history
  • Loading branch information
krsoninikhil committed Jul 3, 2024
1 parent 5d268b0 commit 5614918
Showing 1 changed file with 22 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.concurrent.TimeUnit;

@Component
@Component("redisServiceImpl")
@ConditionalOnAtlasProperty(property = "atlas.redis.service.impl")
public class RedisServiceLocalImpl extends AbstractRedisService {

Expand All @@ -24,17 +25,34 @@ public void init() throws AtlasException {

@Override
public String getValue(String key) {
return null;

// If value doesn't exist, return null else return the value
return (String) redisCacheClient.getBucket(convertToNamespace(key)).get();
}

@Override
public String putValue(String key, String value) {
// Put the value in the redis cache with TTL
redisCacheClient.getBucket(convertToNamespace(key)).set(value);
return value;
}

@Override
public String putValue(String key, String value, int timeout) {
return null;
// Put the value in the redis cache with TTL
redisCacheClient.getBucket(convertToNamespace(key)).set(value, timeout, TimeUnit.SECONDS);
return value;
}

@Override
public void removeValue(String key) {
public void removeValue(String key) {
// Remove the value from the redis cache
redisCacheClient.getBucket(convertToNamespace(key)).delete();
}

private String convertToNamespace(String key){
// Append key with namespace :atlas
return "atlas:"+key;
}

@Override
Expand Down

0 comments on commit 5614918

Please sign in to comment.