Catch errs for Redis
This commit is contained in:
parent
2ec91e3dcf
commit
6b215cc337
@ -113,8 +113,12 @@ public class Document<V> {
|
||||
@NonNull
|
||||
public Map<String, V> toMappedData() {
|
||||
Map<String, V> mappedData = new LinkedHashMap<>(); // The mapped data
|
||||
for (Map.Entry<String, Tuple<java.lang.reflect.Field, V>> entry : this.mappedData.entrySet()) {
|
||||
mappedData.put(entry.getKey(), entry.getValue().getRight());
|
||||
try {
|
||||
for (Map.Entry<String, Tuple<java.lang.reflect.Field, V>> entry : this.mappedData.entrySet()) {
|
||||
mappedData.put(entry.getKey(), entry.getValue().getRight());
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return mappedData;
|
||||
}
|
||||
|
@ -129,7 +129,6 @@ public abstract class Repository<D extends IDatabase<?, ?>, ID, E> {
|
||||
rawDataField = field;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Not the field we're looking for
|
||||
if (!field.isAnnotationPresent(me.braydon.feather.annotation.Field.class)) {
|
||||
continue;
|
||||
|
@ -7,12 +7,10 @@ package me.braydon.feather.database.impl.redis;
|
||||
|
||||
import io.lettuce.core.api.sync.RedisCommands;
|
||||
import lombok.NonNull;
|
||||
import me.braydon.feather.common.Tuple;
|
||||
import me.braydon.feather.data.Document;
|
||||
import me.braydon.feather.database.Repository;
|
||||
import me.braydon.feather.database.impl.redis.annotation.TTL;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@ -86,15 +84,13 @@ public class RedisRepository<ID, E> extends Repository<Redis, ID, E> {
|
||||
commands.hmset(key, document.toMappedData()); // Set the mapped document in the database
|
||||
|
||||
// Handling @TTL annotations
|
||||
for (Tuple<Field, String> tuple : document.getMappedData().values()) {
|
||||
Field field = tuple.getLeft();
|
||||
if (!field.isAnnotationPresent(TTL.class)) { // Missing @TTL
|
||||
continue;
|
||||
}
|
||||
long ttl = field.getAnnotation(TTL.class).value(); // Get the ttl value
|
||||
if (ttl > 0L) { // Value is above zero, set it
|
||||
commands.expire(key, ttl);
|
||||
}
|
||||
Class<?> clazz = entity.getClass(); // The entity class
|
||||
if (!clazz.isAnnotationPresent(TTL.class)) { // Missing @TTL
|
||||
continue;
|
||||
}
|
||||
long ttl = clazz.getAnnotation(TTL.class).value(); // Get the ttl value
|
||||
if (ttl > 0L) { // Value is above zero, set it
|
||||
commands.expire(key, ttl);
|
||||
}
|
||||
}
|
||||
if (multi) { // Execute the commands in bulk
|
||||
|
@ -8,7 +8,7 @@ package me.braydon.feather.database.impl.redis.annotation;
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* Fields flagged with this annotation will
|
||||
* Entities tagged with this annotation will
|
||||
* expire after the amount of defined seconds.
|
||||
*
|
||||
* @author Braydon
|
||||
|
Loading…
x
Reference in New Issue
Block a user