-
Notifications
You must be signed in to change notification settings - Fork 212
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unified interface #356
base: master
Are you sure you want to change the base?
Unified interface #356
Conversation
Implementing #355 |
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.scheduling.annotation.Scheduled; | ||
|
||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we keeping these kind of comments in micro-server?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
woops will remove...
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import com.aol.micro.server.distributed.DistributedMap; | ||
import com.couchbase.client.CouchbaseClient; | ||
|
||
@Slf4j | ||
public class CouchbaseDistributedMapClient<V> implements DistributedMap<V> { | ||
|
||
private final Logger logger = LoggerFactory.getLogger(getClass()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not necessary when you have the lombok @slf4j annotation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good spot thanks
@@ -45,15 +45,26 @@ | |||
@Value("${couchbaseClientOperationTimeout:120000}") | |||
private long opTimeout; | |||
|
|||
@Value("${distributed.cache.default.expiration:691200}") | |||
private int expiresAfterSeconds = 691200; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't need to assign this value will be overwritten by Spring annotation same for line 52,55
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok removed the assignment
|
||
} catch (final Exception e) { | ||
|
||
log.warn("memcache put: {}", e.getMessage()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you mean couchbase instead of memcache ?
private ElasticacheConnectionTester elasticacheConnectionTester; | ||
|
||
|
||
@Scheduled(fixedDelay = 60000) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe expose this as a property ? but have it default to 60000
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed as @scheduled expects a constant I needed to assign it directly in code
try { | ||
result = testConnection(); | ||
} catch (RuntimeException e) { | ||
log.debug("Could not connect to Cache" + e.getMessage()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this log at the right level ? also line 41
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was keeping the convention as it was but I think you are right I will log as error if it cannot connect...
|
||
private final String key; | ||
|
||
private volatile Xor<Void, T> data = Xor.secondary(null); // Void represents |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why Xor<Void, T>
over just Optional<T>
? Or if you're worried about the loaded/not loaded yet case seperately, Future<Optional<T>>
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok I think I can convert to Optional
return currentVersionedKey.withVersion(currentVersionedKey.getVersion() + 1); | ||
} | ||
|
||
private VersionedKey loadKeyFromCouchbase() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not coming from Couchbase here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Il update
|
||
import java.util.Optional; | ||
|
||
public interface DistributedCache<V> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you inherit DistributedMap here?
@@ -20,11 +21,11 @@ | |||
@Rest | |||
public class CouchbaseResource { | |||
|
|||
private final DistributedMap client; | |||
private final DistributedCache client; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd change the reference name as well 😃
No description provided.