DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
Deveel.Data.Store.InMemoryStorageSystem Class Reference
Inheritance diagram for Deveel.Data.Store.InMemoryStorageSystem:
Deveel.Data.Store.IStoreSystem

Public Member Functions

 InMemoryStorageSystem ()
 
void Dispose ()
 
bool StoreExists (string name)
 
InMemoryStore CreateStore (string name)
 
InMemoryStore CreateStore (string name, int hashSize)
 
InMemoryStore OpenStore (string name)
 
bool CloseStore (InMemoryStore store)
 
bool DeleteStore (InMemoryStore store)
 
void SetCheckPoint ()
 Sets a new check point at the current state of this store system. More...
 
void Lock (string lockName)
 
void Unlock (string lockName)
 
- Public Member Functions inherited from Deveel.Data.Store.IStoreSystem
bool StoreExists (String name)
 Returns true if the store with the given name exists within the system, or false otherwise. More...
 
IStore CreateStore (String name)
 Creates and returns a new persistent Store object given the unique name of the store. More...
 
IStore OpenStore (String name)
 Opens an existing persistent Store object in the system and returns the IStore object that contains its data. More...
 
void Lock (String lockName)
 Attempts to lock this store system exclusively so that no other process may access or change the persistent data in the store. More...
 
void Unlock (String lockName)
 Unlocks the exclusive access to the persistent store objects. More...
 

Public Attributes

const int DefaultStoreSize = 1024
 

Private Member Functions

 ~InMemoryStorageSystem ()
 
void Dispose (bool disposing)
 
IStore IStoreSystem. CreateStore (string name)
 
IStore IStoreSystem. OpenStore (string name)
 
bool IStoreSystem. CloseStore (IStore store)
 Closes a store that has been either created or opened with the CreateStore or OpenStore methods. More...
 
bool IStoreSystem. DeleteStore (IStore store)
 Permanently deletes a store from the system - use with care! More...
 

Private Attributes

Dictionary< string, InMemoryStorenameStoreMap
 

Detailed Description

Definition at line 21 of file InMemoryStorageSystem.cs.

Constructor & Destructor Documentation

Deveel.Data.Store.InMemoryStorageSystem.InMemoryStorageSystem ( )
inline

Definition at line 26 of file InMemoryStorageSystem.cs.

26  {
27  nameStoreMap = new Dictionary<string, InMemoryStore>();
28  }
Dictionary< string, InMemoryStore > nameStoreMap
Deveel.Data.Store.InMemoryStorageSystem.~InMemoryStorageSystem ( )
inlineprivate

Definition at line 30 of file InMemoryStorageSystem.cs.

30  {
31  Dispose(false);
32  }

Member Function Documentation

bool IStoreSystem. Deveel.Data.Store.InMemoryStorageSystem.CloseStore ( IStore  store)
inlineprivate

Closes a store that has been either created or opened with the CreateStore or OpenStore methods.

Parameters
store
Returns
Returns true if the store was successfully closed.

Implements Deveel.Data.Store.IStoreSystem.

Definition at line 95 of file InMemoryStorageSystem.cs.

95  {
96  return CloseStore((InMemoryStore) store);
97  }
bool IStoreSystem. CloseStore(IStore store)
Closes a store that has been either created or opened with the CreateStore or OpenStore methods...
bool Deveel.Data.Store.InMemoryStorageSystem.CloseStore ( InMemoryStore  store)
inline

Definition at line 99 of file InMemoryStorageSystem.cs.

99  {
100  if (!StoreExists(store.Name))
101  throw new InvalidOperationException(String.Format("Store {0} does not exist", store.Name));
102 
103  return true;
104  }
A long string in the system.
IStore IStoreSystem. Deveel.Data.Store.InMemoryStorageSystem.CreateStore ( string  name)
inlineprivate

Definition at line 59 of file InMemoryStorageSystem.cs.

59  {
60  return CreateStore(name, DefaultStoreSize);
61  }
IStore IStoreSystem. CreateStore(string name)
InMemoryStore Deveel.Data.Store.InMemoryStorageSystem.CreateStore ( string  name)
inline

Definition at line 63 of file InMemoryStorageSystem.cs.

63  {
64  return CreateStore(name, DefaultStoreSize);
65  }
IStore IStoreSystem. CreateStore(string name)
InMemoryStore Deveel.Data.Store.InMemoryStorageSystem.CreateStore ( string  name,
int  hashSize 
)
inline

Definition at line 67 of file InMemoryStorageSystem.cs.

67  {
68  if (String.IsNullOrEmpty(name))
69  throw new ArgumentNullException("name");
70 
71  lock (this) {
72  if (StoreExists(name))
73  throw new ArgumentException(String.Format("The store {0} already exists.", name));
74 
75  var store = new InMemoryStore(name, hashSize);
76  nameStoreMap[name] = store;
77  return store;
78  }
79  }
A long string in the system.
Dictionary< string, InMemoryStore > nameStoreMap
bool IStoreSystem. Deveel.Data.Store.InMemoryStorageSystem.DeleteStore ( IStore  store)
inlineprivate

Permanently deletes a store from the system - use with care!

Parameters
store

Note that it is quite likely that a store may fail to delete in which case the delete operation should be re-tried after a short timeout.

Returns
Returns true if the store was successfully deleted and the resources associated with it were freed. Returns false if the store could not be deleted.

Implements Deveel.Data.Store.IStoreSystem.

Definition at line 106 of file InMemoryStorageSystem.cs.

106  {
107  return DeleteStore((InMemoryStore) store);
108  }
bool IStoreSystem. DeleteStore(IStore store)
Permanently deletes a store from the system - use with care!
bool Deveel.Data.Store.InMemoryStorageSystem.DeleteStore ( InMemoryStore  store)
inline

Definition at line 110 of file InMemoryStorageSystem.cs.

110  {
111  if (store == null)
112  throw new ArgumentNullException("store");
113 
114  lock (this) {
115  return nameStoreMap.Remove(store.Name);
116  }
117  }
Dictionary< string, InMemoryStore > nameStoreMap
void Deveel.Data.Store.InMemoryStorageSystem.Dispose ( )
inline

Definition at line 34 of file InMemoryStorageSystem.cs.

34  {
35  Dispose(true);
36  GC.SuppressFinalize(this);
37  }
void Deveel.Data.Store.InMemoryStorageSystem.Dispose ( bool  disposing)
inlineprivate

Definition at line 39 of file InMemoryStorageSystem.cs.

39  {
40  if (disposing) {
41  if (nameStoreMap != null) {
42  lock (this) {
43  nameStoreMap.Clear();
44  }
45  }
46  }
47 
48  lock (this) {
49  nameStoreMap = null;
50  }
51  }
Dictionary< string, InMemoryStore > nameStoreMap
void Deveel.Data.Store.InMemoryStorageSystem.Lock ( string  lockName)
inline

Definition at line 123 of file InMemoryStorageSystem.cs.

123  {
124  }
InMemoryStore Deveel.Data.Store.InMemoryStorageSystem.OpenStore ( string  name)
inline

Definition at line 81 of file InMemoryStorageSystem.cs.

81  {
82  lock (this) {
83  InMemoryStore store;
84  if (!nameStoreMap.TryGetValue(name, out store))
85  throw new InvalidOperationException(String.Format("Store {0} does not exist.", name));
86 
87  return store;
88  }
89  }
A long string in the system.
Dictionary< string, InMemoryStore > nameStoreMap
IStore IStoreSystem. Deveel.Data.Store.InMemoryStorageSystem.OpenStore ( string  name)
inlineprivate

Definition at line 91 of file InMemoryStorageSystem.cs.

91  {
92  return OpenStore(name);
93  }
void Deveel.Data.Store.InMemoryStorageSystem.SetCheckPoint ( )
inline

Sets a new check point at the current state of this store system.

This is intended to help journalling check point and recovery systems. A check point is set whenever data is committed to the database. Some systems can be designed to be able to roll forward or backward to different check points. Each check point represents a stable state in the database life cycle.

A checkpoint based system greatly improves stability because if a crash occurs in an intermediate state the changes can simply be rolled back to the last stable state.

An implementation may choose not to implement check points in which case this would be a no-op.

Implements Deveel.Data.Store.IStoreSystem.

Definition at line 119 of file InMemoryStorageSystem.cs.

119  {
120  // Check point logging not necessary with memory store
121  }
bool Deveel.Data.Store.InMemoryStorageSystem.StoreExists ( string  name)
inline

Definition at line 53 of file InMemoryStorageSystem.cs.

53  {
54  lock (this) {
55  return nameStoreMap.ContainsKey(name);
56  }
57  }
Dictionary< string, InMemoryStore > nameStoreMap
void Deveel.Data.Store.InMemoryStorageSystem.Unlock ( string  lockName)
inline

Definition at line 126 of file InMemoryStorageSystem.cs.

126  {
127  }

Member Data Documentation

const int Deveel.Data.Store.InMemoryStorageSystem.DefaultStoreSize = 1024

Definition at line 24 of file InMemoryStorageSystem.cs.

Dictionary<string, InMemoryStore> Deveel.Data.Store.InMemoryStorageSystem.nameStoreMap
private

Definition at line 22 of file InMemoryStorageSystem.cs.


The documentation for this class was generated from the following file: