-
Notifications
You must be signed in to change notification settings - Fork 0
Init #1
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
Init #1
Conversation
@tamnguyenit can we add support to customise the value of TTL? |
can we make the base package name as |
import java.util.concurrent.TimeUnit; | ||
|
||
public class GuavaCachedResponseImpl implements CachedResponseDao { | ||
private static long CACHE_TTL = 30; |
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.
final
here?
|
||
public class GuavaCachedResponseImpl implements CachedResponseDao { | ||
private static long CACHE_TTL = 30; | ||
private static Cache<String, String> CACHE = |
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.
final
here?
try { | ||
jsonEntity = OBJECT_MAPPER.writeValueAsString(cachedResponseEntity); | ||
} catch (JsonProcessingException ex) { | ||
ex.printStackTrace(); |
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 we use logger to print the stack trace?
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.
definitely, I will add it later, btw GuavaCachedResponseImpl is just an simple example how to implement CachedResponse, we are not going to use this, We will implement RedisCachedResponseImpl
in our curiosity/akasha. This is the only one thing you need to do in order to use this lib.
private String responseBody; | ||
private List<Cookie> cookies; | ||
private FluentCaseInsensitiveStringsMap headers; | ||
private Integer statusCode; |
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 we use primitive int
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.
Some how people still handle the case when status is null here, so I think if we keep as Integer we can also handle it https://github.com/AsyncHttpClient/async-http-client/blob/master/client/src/main/java/org/asynchttpclient/netty/NettyResponse.java#L153
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.
oh, okay. can we return it as a null on the getter instead of returning 0 here https://github.com/wego/async-http-cache/pull/1/files#diff-ceec446c2bb5f8d2ba305936fa32ebdeR25?
} | ||
|
||
public String getResponseBodyExcerpt(int maxLength, String charset) throws IOException { | ||
return null; |
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 we throw UnsupportedOperationException
instead returning null?
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.
this is still unimplemented yet, we will not implement all override functions now. We only implement the function we need for now.
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.
yeah, thats why throw UnsupportedException instead of returning null so that the client will know that it is not yet implemented.
Added TTL @codenut |
|
||
@Inject private CachedResponseService cachedResponseService; | ||
|
||
@Inject private AsyncHttpClient asyncHttpClient; |
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.
this should not be injected since this is assisted and will be set for each provider
No description provided.