Geeks With Blogs
Sonam Singh
I was writing an app in which i needed to store a dictionary..
I thought to post the code..:
 public void StoreDictionary(Dictionary<string,FileInfo> files)
        {
            FileStream fs = new FileStream(fileName, FileMode.Create, FileAccess.Write);
            BinaryFormatter bf = new BinaryFormatter();

            bf.Serialize(fs, files);
            fs.Close();
        
        }
   public  Dictionary<string, FileInfo> RetrieveDictionary()
        {

            FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read);


            BinaryFormatter bf = new BinaryFormatter();
            Dictionary<string,FileInfo> filedic=(Dictionary<string, FileInfo>)bf.Deserialize(fs);
            fs.Close();
            return filedic;
        }..................................................




But for my app,I need to access,update and query the dictionary at very  rapid rate..
Serializing and deserializing ,again and again is Just Impossible in my app.

So, i am  choosing  a better option, a light ,easy but powerful database..
And the only database  that comes to my mind for this is db4o......http://www.db4o.com

Its the easiest yet powerful Object oriented Database and that too Open Source..
 
With just 2 lines,u can store an object.

But i don't think i can store a dictionary(Collection) directly...Insead.. I will store key value pairs from dictionary in the database...That Way ,I can query,Update without  any significant overhead..

I really like db4o personally....U should all check out before using any other one... Posted on Tuesday, December 9, 2008 8:56 PM .Net | Back to top


Comments on this post: Storing A dictionary in a file

# re: Storing A dictionary in a file
Requesting Gravatar...
You are right with db4o and collections. The idea of db4o is to store domain objects first. But nevertheless these domain object can include any collection or hashes you like.

Best
Stefan Edlich
Left by Stefan Edlich on Dec 11, 2008 1:02 AM

# re: Storing A dictionary in a file
Requesting Gravatar...
DB4O is quite expensive to license. You should look into that before committing to it.
Left by Dave on Dec 12, 2008 12:12 AM

# re: Storing A dictionary in a file
Requesting Gravatar...
Hi Dave,

Actually,This is a personal app(a project for experience)..And it will be open source ..So,Db4o should work until i am not commercializing it..
I don't know how much it costs for commercial apps but yeah i believe it might be expensive..
But i am not able to think of any other database now..Storing in File is not suitable when u want query ,update frequently..maybe 100 queries/s or more.

Can u suggest some better option u may know..
cheers,
sonam
Left by sonam on Dec 12, 2008 3:45 AM

# re: Storing A dictionary in a file
Requesting Gravatar...
You can have a look at NeoDatis ODB. This is equivalent in terms of functionalities and is LGPL.

Olivier
Left by Olivier Smadja on Mar 03, 2009 6:27 AM

Your comment:
 (will show your gravatar)


Copyright © sonam | Powered by: GeeksWithBlogs.net