| 100 | } |
| 101 | |
| 102 | private void dbSave(@NotNull CacheObject value) throws RocksDBException, IOException { |
| 103 | var id = value.cacheId(); |
| 104 | if (id.isEmpty()) |
| 105 | throw new IllegalArgumentException(); |
| 106 | |
| 107 | var bb = ByteBuffer.Allocate(); |
| 108 | bb.WriteString(value.cacheId()); |
| 109 | value.encode(bb); |
| 110 | |
| 111 | var key = ByteBuffer.Allocate(128); |
| 112 | key.WriteString(id); |
| 113 | db.put(RocksDatabase.getDefaultWriteOptions(), key.Bytes, 0, key.WriteIndex, bb.Bytes, 0, bb.WriteIndex); |
| 114 | |
| 115 | today().write((id + "\n").getBytes(StandardCharsets.UTF_8)); |
| 116 | } |
| 117 | |
| 118 | private @NotNull FileOutputStream today() throws IOException { |
| 119 | var nowDays = System.currentTimeMillis() / (24 * 60 * 60 * 1000); |