Update to 0.2.0

This commit is contained in:
Andrea Cavalli 2023-07-22 00:56:13 +02:00
parent b603d78db5
commit ec093acbc2
3 changed files with 11 additions and 31 deletions

View File

@ -23,7 +23,7 @@
<groupId>org.warp.filesponge</groupId>
<artifactId>FileSponge</artifactId>
<version>0.1.0</version>
<version>0.2.0</version>
<name>FileSponge</name>

View File

@ -31,7 +31,7 @@ import java.util.function.Predicate;
import java.util.stream.Stream;
import reactor.util.function.Tuple2;
public interface DiskCache extends URLsDiskHandler, URLsWriter, IBackuppable, SafeCloseable {
public interface DiskCache extends URLsDiskHandler, URLsWriter, SafeCloseable {
void writeMetadataSync(URL url, Metadata metadata);
@ -58,10 +58,9 @@ public interface DiskCache extends URLsDiskHandler, URLsWriter, IBackuppable, Sa
return new DiskCacheImpl(db, dict1, dict2, shouldCache);
}
static DiskCache openCustom(LLKeyValueDatabase db,
LLDictionary fileContent,
static DiskCache openCustom(LLDictionary fileContent,
LLDictionary fileMetadata,
Predicate<URL> shouldCache) {
return new DiskCacheImpl(db, fileContent, fileMetadata, shouldCache);
return new DiskCacheImpl(null, fileContent, fileMetadata, shouldCache);
}
}

View File

@ -24,19 +24,13 @@ import static org.warp.filesponge.FileSponge.BLOCK_SIZE;
import it.cavallium.buffer.Buf;
import it.cavallium.buffer.BufDataInput;
import it.cavallium.buffer.BufDataOutput;
import it.cavallium.dbengine.client.IBackuppable;
import it.cavallium.dbengine.database.ColumnUtils;
import it.cavallium.dbengine.database.LLDatabaseConnection;
import it.cavallium.dbengine.database.LLDictionary;
import it.cavallium.dbengine.database.LLDictionaryResultType;
import it.cavallium.dbengine.database.LLKeyValueDatabase;
import it.cavallium.dbengine.database.UpdateMode;
import it.cavallium.dbengine.database.UpdateReturnMode;
import it.cavallium.dbengine.database.serialization.SerializationException;
import it.cavallium.dbengine.rpc.current.data.DatabaseOptions;
import it.cavallium.dbengine.utils.StreamUtils;
import it.unimi.dsi.fastutil.booleans.BooleanArrayList;
import java.util.List;
import java.util.Objects;
import java.util.function.Predicate;
import java.util.stream.Stream;
@ -51,17 +45,17 @@ import reactor.util.function.Tuples;
class DiskCacheImpl implements DiskCache {
private final DiskMetadataSerializer diskMetadataSerializer;
private final LLKeyValueDatabase db;
@Nullable
private final LLKeyValueDatabase ownedDb;
private final LLDictionary fileContent;
private final LLDictionary fileMetadata;
private final Predicate<URL> shouldCache;
public DiskCacheImpl(LLKeyValueDatabase db,
DiskCacheImpl(@Nullable LLKeyValueDatabase ownedDb,
LLDictionary fileContent,
LLDictionary fileMetadata,
Predicate<URL> shouldCache) {
this.db = db;
this.ownedDb = ownedDb;
this.fileContent = fileContent;
this.fileMetadata = fileMetadata;
this.diskMetadataSerializer = new DiskMetadataSerializer();
@ -305,21 +299,8 @@ class DiskCacheImpl implements DiskCache {
@Override
public void close() {
db.close();
}
@Override
public void pauseForBackup() {
db.pauseForBackup();
}
@Override
public void resumeAfterBackup() {
db.resumeAfterBackup();
}
@Override
public boolean isPaused() {
return db.isPaused();
if (ownedDb != null) {
ownedDb.close();
}
}
}