Saturday, February 13, 2010 6:30 PM
As I stated in my previous posts here and here, I have set out to write my own NoSQL database simply because I can – well not really but because it will give me the edge, learning experience will be great and there isn’t really too many options when it comes to native .NET NoSQL Databases. I want to be able to build web applications without the RDBMS overhead and schema design time.
I haven’t done much yet with distributed or replicating side of things yet, so far all I wanted was a prototype to show that it works. I don’t have a name yet, therefore, I’m allowed to call it random names. I want to build it in such a way that it will support 4 modes listed below.
- In Memory only - sort of a caching server
- In Memory with Persistent – a caching server that can persist its state and recover
- Network – this mode will allow you to setup the server itself on a different machine and access it over the network
- Network Replicated – data is replicated across other nodes which gives you the ability to load balance, it will support the “Eventually Consistent Model”.
I’ve proven to myself that 1 & 2 is completely feasible as I have a working prototype that works with amazing speeds, however, I’m still working on 3 & 4 as a simple communication protocol is not that easy to develop. What I have so far is way too complex, I get lost in my own code – so I’m re-writing while trying hard so that the perfectionist side of me does eat up the best of my time.
My NoSQL database currently supports the following functions – in progress.
/// <summary>
/// Version Alpha 0.1.3
/// </summary>
interface IClient
{
/// <summary>
/// Truncates the database and remove all old versions
/// from the journal file system structure, if your database has
/// grown outrageously, this is what you want to do.
/// </summary>
void Truncate();
/// <summary>
/// Shuts down the database, why would you want to do that?
/// </summary>
void ShutDown();
/// <summary>
/// Stores an object into the storage unit
/// </summary>
/// <param name="key">the key that uniquely identifies the object</param>
/// <param name="obj">the object to store</param>
void Put(string key, object obj);
/// <summary>
/// stores an object in the database and return the object ID (OID)
/// that was generated for you, if you were so lazy not to provide a key
/// </summary>
/// <param name="value">the value to store</param>
/// <returns>the key (OID)</returns>
string Put(object value);
/// <summary>
/// Gets a stored object by name
/// </summary>
T Get<T>(string key);
/// <summary>
/// removes a record from the database
/// </summary>
/// <param name="Key">the key of the record to remove</param>
/// <returns>true or false indicating the record was removed of not</returns>
void Delete(string Key);
/// <summary>
/// returns a list of all keys
/// </summary>
/// <returns>ilist of keys</returns>
IList<string> Keys();
/// <summary>
/// returns a list of keys that match the specified pattern
/// </summary>
/// <param name="pattern">the pattern to search for</param>
/// <returns>ilist of keys that match</returns>
IList<string> Keys(string pattern);
/// <summary>
/// indicates whether or not the specified key exist in this database
/// </summary>
/// <param name="key">the key to search for</param>
/// <returns>boolean indicate if the key was found or not</returns>
bool Exists(string key);
/// <summary>
/// saves this database to disk
/// will only work if you are using in-memory mode and you decide
/// to save it to disk for some unknown reason
/// </summary>
/// <param name="async">indicates a synchronous or asynchronous write</param>
void Save(bool async);
/// <summary>
/// puts an entry into a list that is part of the database, meaning
/// the value itself is of type IList
/// Works for IList or ArrayList, etc.
/// </summary>
/// <param name="key">the database key</param>
/// <param name="listKey">the key to the object with the IList object</param>
/// <param name="listValue">this object itself is of type IList</param>
void ListPut(string key, string listKey, object value);
/// <summary>
/// puts an entry into the database that its value is a Hashtable
/// </summary>
/// <param name="key">the database entry key</param>
/// <param name="hashKey">the hashtable entry key</param>
/// <param name="value">the hashtable value</param>
void HashPut(string key, string hashKey, object value);
/// <summary>
/// increment the value of this key by 1, therefore, the
/// value of this key as to be a number
/// </summary>
/// <remarks>this could be very useful for tracking ids
/// that are some sort of a unique key such as a primary key in an RDBMS</remarks>
/// <param name="key">the key to increment</param>
/// <returns>returns the new incremented value</returns>
int Increment(string key);
/// <summary>
/// decreases the value of this key by 1, therefore,
/// the value of this key as to be a number
/// </summary>
/// <param name="key">the key which value to decrement</param>
/// <returns>returns the new decremented value</returns>
int Decrement(string key);
/// <summary>
/// renames the key of and entry in this database to a new key
/// </summary>
void Rename(string oldKey, string newKey);
/// <summary>
/// gets multiple keys and return there values
/// </summary>
/// <param name="keys">the list of keys to search for</param>
/// <returns>an IDictionary with a list of keys and objects that were found</returns>
IDictionary<string, object> MultiGet(IList<string> keys);
/// <summary>
/// inserts multiple values into the database
/// </summary>
/// <param name="keys">the list of keys</param>
/// <param name="values">the list of values</param>
void MultiPut(IList<string> keys, IList<object> values);
/// <summary>
/// will traverse through an IDictionary and put all
/// of its entries into the database
/// </summary>
/// <param name="entries">the KeyValuePair entries that need to be inserted</param>
void MultiPut(IDictionary<string, object> entries);
/// <summary>
/// will traverse through a set of key/value pairs and
/// insert each entry into the database
/// </summary>
/// <param name="entries">the key/value pairs that need to be inserted</param>
void MultiPut(KeyValuePair<string, object> entries);
}