use of com.enonic.xp.blob.BlobRecord in project xp by enonic.
the class FileBlobStoreTest method getRecord.
@Test
public void getRecord() {
final BlobKey key = createRecord("hello").getKey();
final BlobRecord record = this.blobStore.getRecord(this.segment, key);
assertNotNull(record);
}
use of com.enonic.xp.blob.BlobRecord in project xp by enonic.
the class CachedBlobStore method addRecord.
@Override
public BlobRecord addRecord(final Segment segment, final ByteSource in) throws BlobStoreException {
final BlobRecord record = this.store.addRecord(segment, in);
addToCache(record);
return record;
}
use of com.enonic.xp.blob.BlobRecord in project xp by enonic.
the class ReadThroughBlobStore method getRecord.
@Override
public BlobRecord getRecord(final Segment segment, final BlobKey key) throws BlobStoreException {
BlobRecord record = this.readThroughStore.getRecord(segment, key);
if (record != null) {
return record;
}
record = store.getRecord(segment, key);
if (record != null) {
this.readThroughStore.addRecord(segment, record);
}
return record;
}
use of com.enonic.xp.blob.BlobRecord in project xp by enonic.
the class BlobStoreFactoryTest method doTestProviderStore.
private void doTestProviderStore(final boolean cache) {
final MemoryBlobStore memory1 = new MemoryBlobStore();
final MemoryBlobStoreProvider provider1 = new MemoryBlobStoreProvider("memory1", memory1, createProviderConfig("memory2", true));
final MemoryBlobStore memory2 = new MemoryBlobStore();
final MemoryBlobStoreProvider provider2 = new MemoryBlobStoreProvider("memory2", memory2, createProviderConfig(null, false));
final BlobStoreProviders blobStoreProviders = new BlobStoreProviders();
blobStoreProviders.add(provider2);
final BlobStore finalBlobStore = BlobStoreFactory.create().provider(provider1).config(createBlobstoreConfig(cache)).providers(blobStoreProviders).build().execute();
assertNotNull(finalBlobStore);
final Segment segment = Segment.from("test", "blob");
final BlobRecord record = finalBlobStore.addRecord(segment, ByteSource.wrap("hei".getBytes()));
assertEquals(finalBlobStore.getRecord(segment, record.getKey()), memory1.getRecord(segment, record.getKey()));
assertEquals(finalBlobStore.getRecord(segment, record.getKey()), memory2.getRecord(segment, record.getKey()));
}
use of com.enonic.xp.blob.BlobRecord in project xp by enonic.
the class CachedBlobStoreTest method lastModified.
@Test
public void lastModified() throws Exception {
final BlobRecord record = newRecord("0123", 10L, Instant.now().toEpochMilli());
Mockito.when(this.blobStore.getRecord(segment, record.getKey())).thenReturn(record);
final BlobRecord firstRetrieval = this.cachedBlobStore.getRecord(this.segment, record.getKey());
assertNotNull(firstRetrieval);
assertEquals(firstRetrieval.lastModified(), record.lastModified());
final BlobRecord secondRetrieval = this.cachedBlobStore.getRecord(this.segment, record.getKey());
assertNotNull(secondRetrieval);
assertEquals(secondRetrieval.lastModified(), record.lastModified());
}
Aggregations