MCPcopy Create free account
hub / github.com/e2wugui/zeze / Cache

Method Cache

ZezeJava/ZezeJava/src/main/java/Zeze/Util/Cache.java:36–48  ·  view source on GitHub ↗

创建LocalCache @param name Cache名字,直接作为目录名字,需要注意有些字符可能不能用。 @param lruCapacity 解码后的对象lru容量。 @param loader 根据id装载对象实例的。 @param decoder 根据id和数据创建出对象实例。

(@NotNull String name, int lruCapacity, @NotNull Function<String, CacheObject> loader,
				 @NotNull BiFunction<String, ByteBuffer, CacheObject> decoder)

Source from the content-addressed store, hash-verified

34 * @param decoder 根据id和数据创建出对象实例。
35 */
36 public Cache(@NotNull String name, int lruCapacity, @NotNull Function<String, CacheObject> loader,
37 @NotNull BiFunction<String, ByteBuffer, CacheObject> decoder) throws RocksDBException {
38 this.name = name;
39 this.loader = loader;
40 this.decoder = decoder;
41
42 //noinspection ResultOfMethodCallIgnored
43 new File(name).mkdirs();
44 db = RocksDB.open(name);
45 lru = new ConcurrentLruLike<>(name, lruCapacity);
46 // 每天6:30尝试删除旧的项。
47 Task.scheduleAt(6, 30, this::tryRemove);
48 }
49
50 public void close() throws IOException {
51 if (todayFile != null)

Callers

nothing calls this directly

Calls 2

scheduleAtMethod · 0.95
openMethod · 0.65

Tested by

no test coverage detected