I have a Java system that consumes an API. A few days ago, we started facing the following problem: the remote API was receiving too many requests from my system. Back in the system's early days, it was not a major concern, but little by little the system's performance was getting worse and worse, since my data was growing and I made multiple requests for each entity. I noticed many of the network requests I made were not really necessary, since the data was not updated very frequently. So, I implemented a class that, when my system starts, makes an over-eager loading of all the remote API data. When I create/update an entity, I load it before any request is made. I treat deletion accordingly. And the remote API also notifies me when any change is made so I can stay updated even when this change is made outside my system.

What I really want to know is: is there any name for this practice? Any known design pattern ? I must say I've done a little research and I think it is a proxy pattern but, again, I'm not very sure (in fact, most of the design patterns look very similar), and I'm not really that much into design patterns.

有帮助吗?

解决方案

I would call it a Cache System to what you implemented. Not sure if there is a dessign pattern for this though.

Also, the fact that the remote API notifies you when any change is made, might have been done using the observer pattern.

其他提示

It's not quite a proxy pattern as the proxy pattern falls more under the heading of 'lazy loading'. From the description of the Proxy Pattern specified in Design Patterns (Group of Four Book):

One reason for controlling access to an object is to defer the full cost of its creation and initialization until we actually need to use it

I'm not sure what you'd call it other than over-eager loading

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top