@@ -109,7 +109,7 @@ addData!(dfg::AbstractDFG, blobstorekey::Symbol, label::Symbol, key::Symbol, blo
109
109
kwargs... )
110
110
111
111
function addData! (dfg:: AbstractDFG , blobstore:: AbstractBlobStore , label:: Symbol , key:: Symbol ,
112
- blob:: Vector{UInt8} , timestamp= now (localzone ()); description= " " , mimeType = " " , id:: UUID = uuid4 (), hashfunction = sha256)
112
+ blob:: Vector{UInt8} , timestamp= now (localzone ()); description= " " , mimeType = " application/octet-stream " , id:: UUID = uuid4 (), hashfunction = sha256)
113
113
114
114
115
115
entry = BlobStoreEntry (key, id, blobstore. key, bytes2hex (hashfunction (blob)),
196
196
function deleteDataBlob! (store:: FolderStore{T} , entry:: BlobStoreEntry ) where T
197
197
blobfilename = joinpath (store. folder," $(entry. id) .dat" )
198
198
entryfilename = joinpath (store. folder," $(entry. id) .json" )
199
-
199
+
200
200
data = getDataBlob (store, entry)
201
201
rm (blobfilename)
202
202
rm (entryfilename)
203
203
return data
204
204
end
205
+
206
+ # #==============================================================================
207
+ # # InMemoryBlobStore
208
+ # #==============================================================================
209
+ export InMemoryBlobStore
210
+ struct InMemoryBlobStore{T} <: AbstractBlobStore{T}
211
+ key:: Symbol
212
+ blobs:: Dict{UUID, T}
213
+ end
214
+
215
+ InMemoryBlobStore {T} (storeKey:: Symbol ) where T = InMemoryBlobStore {Vector{UInt8}} (storeKey, Dict {UUID, T} ())
216
+ InMemoryBlobStore (storeKey:: Symbol = :default_inmemory_store ) = InMemoryBlobStore {Vector{UInt8}} (storeKey)
217
+
218
+ function getDataBlob (store:: InMemoryBlobStore{T} , entry:: BlobStoreEntry ) where T
219
+ return store. blobs[entry. id]
220
+ end
221
+
222
+ function addDataBlob! (store:: InMemoryBlobStore{T} , entry:: BlobStoreEntry , data:: T ) where T
223
+ if haskey (store. blobs, entry. id)
224
+ error (" Key '$(entry. id) ' blob already exists." )
225
+ end
226
+ return store. blobs[entry. id] = data
227
+ end
228
+
229
+ function updateDataBlob! (store:: InMemoryBlobStore{T} , entry:: BlobStoreEntry , data:: T ) where T
230
+ if haskey (store. blobs, entry. id)
231
+ @warn " Key '$(entry. id) ' doesn't exist."
232
+ end
233
+ return store. blobs[entry. id] = data
234
+ end
235
+
236
+ function deleteDataBlob! (store:: InMemoryBlobStore{T} , entry:: BlobStoreEntry ) where T
237
+ return pop! (store. blobs, entry. id)
238
+ end
0 commit comments