SEPARAR INTERFACES
public interface InvoiceRepository { Invoice findById(int id); List<Invoice> list(); boolean create(Invoice invoice); boolean update(Invoice invoice); boolean delete(Invoice invoice);
La cache podría ir en una clase decoradora o wrapper:
public class CachedInvoiceRepository implements InvoiceRepository { private final InvoiceRepository delegate; private final Map<Integer, Invoice> cache = new HashMap<>(); // métodos que usan cache y llaman al delegate }
SEPARAR INTERFACES
public interface InvoiceRepository { Invoice findById(int id); List<Invoice> list(); boolean create(Invoice invoice); boolean update(Invoice invoice); boolean delete(Invoice invoice);La cache podría ir en una clase decoradora o wrapper:
public class CachedInvoiceRepository implements InvoiceRepository { private final InvoiceRepository delegate; private final Map<Integer, Invoice> cache = new HashMap<>(); // métodos que usan cache y llaman al delegate }