Skip to content

pull#1

Open
dosstacy wants to merge 48 commits intobranchfrom
master
Open

pull#1
dosstacy wants to merge 48 commits intobranchfrom
master

Conversation

@dosstacy
Copy link
Owner

No description provided.

pom.xml Outdated
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>20</source>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use lts

<version>8.0.30</version>
</dependency>

<dependency>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

first dependency, then plugins


import static java.util.Objects.nonNull;

public class Main {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why Main?

RedisRepository cityRedisRepository = new RedisRepository();

System.out.println("Querying Country by ID...");
for (int i = 0; i < 15; i++) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what 15 mean?

try {
mapper.readValue(value, CityCountry.class);
} catch (JsonProcessingException e) {
e.printStackTrace(System.out);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it informative? use logger

private static final Logger LOGGER = LoggerFactory.getLogger(CityService.class);

public RedisRepository() {
jedis = new UnifiedJedis("redis://127.0.0.1:6379");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make "redis://127.0.0.1:6379" constant


private int getCount(String key) {
String count = jedis.sendCommand(() -> SafeEncoder.encode("TOPK.COUNT"), SafeEncoder.encodeMany(TOPK_NAME, key)).toString();
return Integer.parseInt(count.replaceAll("[\\[\\]]", ""));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make "[\[\]]" constant

return objectMapper.writeValueAsString(entity);
} catch (Exception e) {
LOGGER.error("Error serializing object: {}", e.getMessage());
return null;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why null?

private <T> T deserialize(String serializedEntity, Class<T> clazz) {
try {
return objectMapper.readValue(serializedEntity, clazz);
} catch (Exception e) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why u are catching exception?

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