Java中的远程方法调用是实现分布式系统的主要技术之一,但在实际应用中,过多重复的远程方法调用会影响程序性能。给出了一种基于客户端缓存的RMI方法,使用客户端本地缓存保存使用过的存根和结果,当客户端需要调用远程方法时首先查询缓存中是否存在将要调用的存根或结果,如果存在就直接从缓存中返回而不需要通过网络进行RMI调用。经过性能比较可以发现客户端缓存的加入能有效减少重复RMI调用的次数,从而提高程序响应速度并减少了占用的网络带宽。
Java remote method invocation (RMI) is one of approaches to develop distributed system, but in practice too many repeated remote method invocations may affect the performance of application. A method for RMI based on client side cache is given. A client first query in local cache whether there is the stub or result the client tries to invocate, and if they exist the client will directly use them without further remote method call through the network. The performance comparison shows that the method improves the performance of RMI by decreasing repeated invocation times and reducing network bandwidth occupied.