Home  >  Article  >  Java  >  What are the two modes of java caching

What are the two modes of java caching

WBOY
WBOYforward
2023-04-19 23:46:131190browse

1. Description

Store objects that are frequently called by the program or system in the memory. When called again, the object can be quickly obtained from the memory without creating it. New duplicate instance.

2. Two modes

(1) Memory cache: The cached data is stored in the memory space of the server.

Fast speed, but limited resources.

(2) File cache: The cache data is stored in the hard disk space of the server.

The capacity is large, but the speed is slow, especially when the number of caches is huge.

3. Function

is a method to improve performance. This can reduce system overhead and improve system efficiency.

4. Example

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
 
@Getter
@Setter
@AllArgsConstructor
public class CacheEntity {
/**
 * 数据主体
 */
private Object data;
/**
 * 超时时长,0永不超时
 */
private Long timeout;
/**
 * 缓存设置初始时间
 */
private Long initialTime;
}

The above is the detailed content of What are the two modes of java caching. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete