DataAccess

Namespace: WellFired.Guacamole.DataStorage

Implements: WellFired.Guacamole.DataStorage.Data.IDataAccess, WellFired.Guacamole.DataStorage.Data.Synchronization.IStoredDataWatcherListener

Description

DataAccess is a hub to access data provided by a IDataStorageService”. It offers : <list type=”bullet”> the possibility to synchronize your IDataProxy with the stored data if ever it is changed (by modifying a file on a file storage for example) A mechanism to ensure your data is always updated to its last version before to track it The possibility to save content of your IDataProxy data in the storage only when you request it and only if data in your proxy was modified, avoiding to constantly write to the storage Note that a DataAccess is thread safe with himself. If ever you have several instance of it tracking data in the same emplacement, you may want to make use of the possibility of assigning a thread synchronizer id in the constructor method.

Public Static Methods

void InitializeSharedThreadLock ( IKeyBasedReadWriteLock readWriteLock, bool forceReinitialization = false )

Public Methods

  DataAccess ( IDataStorageService dataStorageService, IDataCacher dataCacher, IStoredDataUpdater storedDataUpdater, IStoredDataWatcher storedDataWatcher = null, string synchronizeID = null )
void Track ( string key, IDataProxy dataProxy )
void Save ( string key )
void DoStoredDataChanged ( string key )

Breakdown

  • void InitializeSharedThreadLock ( IKeyBasedReadWriteLock readWriteLock, bool forceReinitialization = false )
  • DataAccess ( IDataStorageService dataStorageService, IDataCacher dataCacher, IStoredDataUpdater storedDataUpdater, IStoredDataWatcher storedDataWatcher = null, string synchronizeID = null )

    Description

    Constructor of DataAccess

    Parameters

    dataStorageService The key base storage service where data is stored
    dataCacher The cacher ensuring the cached data is updated correctly
    storedDataUpdater The object in charge of updating the data to its current version
    storedDataWatcher An optional data watcher if the storage offers the possibility to detect data changes.
    synchronizeID Two DataAccess sharing the same id will work in a thread safe environment. For example, data will not be read while it is being updated. Note that it is key based. If one key of the storage is being saved, it will not prevent other threads from writing in different key locations. Also, if no id is specified then a unique id based on .Net GUID implementation will be generated.
  • void Track ( string key, IDataProxy dataProxy )

    Description

    Load stored data in your data proxy and ensure any changes to the stored data is propagated to your data proxy.

    Parameters

    key The key where is located the data
    dataProxy Your data proxy. An implementation of the proxy is provided by DataProxy<T>
  • void Save ( string key )

    Description

    Force DataAccess to save the data from your data proxy in the storage. It will save it only if data changed in your proxy.

    Parameters

    key The key where is located the data
  • void DoStoredDataChanged ( string key )