Skip to content

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

Merged
merged 38 commits into from
May 9, 2017
Merged

Init #1

merged 38 commits into from
May 9, 2017

Conversation

tamnguyenit
Copy link
Contributor

No description provided.

@codenut
Copy link
Contributor

codenut commented May 8, 2017

@tamnguyenit can we add support to customise the value of TTL?

@codenut
Copy link
Contributor

codenut commented May 8, 2017

can we make the base package name as com/wego/async-http-cache instead of just com/wego?

import java.util.concurrent.TimeUnit;

public class GuavaCachedResponseImpl implements CachedResponseDao {
private static long CACHE_TTL = 30;
Copy link
Contributor

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 =
Copy link
Contributor

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();
Copy link
Contributor

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?

Copy link
Contributor Author

@tamnguyenit tamnguyenit May 8, 2017

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;
Copy link
Contributor

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?

Copy link
Contributor Author

@tamnguyenit tamnguyenit May 8, 2017

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

Copy link
Contributor

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;
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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.

@tamnguyenit
Copy link
Contributor Author

Added TTL @codenut


@Inject private CachedResponseService cachedResponseService;

@Inject private AsyncHttpClient asyncHttpClient;
Copy link
Contributor

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

@tamnguyenit tamnguyenit merged commit 0abe30f into master May 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants