Class Store<T>
A store that will be incrementally saved on the HDD. Thread-safe and process-safe.
public abstract class Store<T> : IDisposable where T : new()
Type Parameters
TThe type of elements in the store.
- Inheritance
-
Store<T>
- Implements
- Derived
- Extension Methods
Constructors
Store(Stream)
protected Store(Stream stream)
Parameters
streamStream
Fields
lockObject
protected object lockObject
Field Value
stream
protected Stream stream
Field Value
transaction
protected int transaction
Field Value
Properties
AutoLoadNewValues
Gets or sets a flag specifying if a Save should also load new values that happened in between.
public bool AutoLoadNewValues { get; set; }
Property Value
UseTransaction
Gets or sets a flag specifying if the index map changes should be kept aside instead of being committed immediately.
public bool UseTransaction { get; set; }
Property Value
Methods
AddLoaded(T)
Adds a value that has already been saved in the store (saved state).
protected abstract void AddLoaded(T item)
Parameters
itemTThe item.
AddUnsaved(T, int)
Adds a value that has not yet been saved in the store (pending state).
protected abstract void AddUnsaved(T item, int transaction)
Parameters
itemTThe item.
transactionintThe transaction index.
AddValue(T)
Adds a value to the store.
public void AddValue(T item)
Parameters
itemTThe item.
AddValues(IEnumerable<T>)
Adds multiple values to the store
public void AddValues(IEnumerable<T> values)
Parameters
valuesIEnumerable<T>The values.
BuildContext(Stream)
protected virtual object BuildContext(Stream stream)
Parameters
streamStream
Returns
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. Waits for pending operation to finish, if any. Note that it does not write pending transaction if Save() has not been called before.
public void Dispose()
GetPendingItems(int)
Gets the list of pending items for a given transaction index.
protected abstract IEnumerable<T> GetPendingItems(int transaction)
Parameters
transactionintThe transaction index.
Returns
- IEnumerable<T>
LoadNewValues()
Refreshes URL to ObjectId mapping from the latest results in the index file.
public bool LoadNewValues()
Returns
- bool
True on success.
ReadEntries(Stream)
protected virtual List<T> ReadEntries(Stream localStream)
Parameters
localStreamStream
Returns
- List<T>
RemoveUnsaved(IEnumerable<T>, int)
Removes values that have not yet been saved (pending state).
protected virtual void RemoveUnsaved(IEnumerable<T> items, int transaction)
Parameters
itemsIEnumerable<T>The items.
transactionintThe transaction index.
RemoveUnsaved(T, int)
Removes a value that has not yet been saved (pending state).
protected abstract void RemoveUnsaved(T item, int transaction)
Parameters
itemTThe item.
transactionintThe transaction index.
Reset()
Resets the store to an empty state.
public void Reset()
ResetInternal()
Resets the store to an empty state, to be implemented by subclasses if necessary.
protected virtual void ResetInternal()
Save()
Saves the newly added mapping (only necessary when UseTransaction is set to true).
public void Save()
WriteEntry(Stream, T)
protected virtual void WriteEntry(Stream stream, T value)
Parameters
streamStreamvalueT