[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

storing data in memory vs saving to DB

Posted on 2012-09-16
3
Medium Priority
?
473 Views
Last Modified: 2012-10-02
i am reading from a text file and creating a dictionary from the words there.  is it better to create the dictionary in memory or save to a DB and retrieve it later.  what about saving to a file?  the current text file is not that big, ~2000 lines, 8000 words.
0
Comment
Question by:mmingfeilam
3 Comments
 
LVL 5

Assisted Solution

by:sameer_goyal
sameer_goyal earned 668 total points
ID: 38403157
The decision to choose between in-memory storage or db or text file will depend on your answers to the following:

1. For how long do you want the dictionary to persist?
2. What will the frequency of you referring this dictionary created in your program?
3. For now it is 2000 lines. Is there a chance that this can grow?

Now, if you want the dictionary persist forever, and you will just fetch the data in dictionary and use it over and over again, use either the file or db

But if you want to have the dictionary available for a small amount of time, may be go for the in-memory storage.
0
 
LVL 40

Assisted Solution

by:Jacques Bourgeois (James Burger)
Jacques Bourgeois (James Burger) earned 664 total points
ID: 38403230
A database would probably overkill with only one table.

A file would probably be sufficient, and is more easily portable. You can copy it in a pinch.

Then it depends on the use of the dictionary once it is created. If it is only for consultation, then the file should be sufficient. If it is used to check other text, then you might get a better performance loading it in memory because searches would be better that way.

Tell us more about what you intend to do with the dictionary, we might come up with other ideas.
0
 
LVL 8

Accepted Solution

by:
ee_reach earned 668 total points
ID: 38404094
I would also ask how many of these dictionaries are going to be active at any given time.  

E.g., will you have multiple users starting this program and each would have his own copy of the file and the text be different for each one?  If so, that could end up being a lot of data in memory.

If you'll only ever have one copy running at any given time, then I would want to hear more about what you intend to do with it.

Another consideration - how important is it to have this file later?  E.g., is it mission critical to have a copy of the data saved somewhere when your program exits (whether your program exits intentionally or unintentionally.)  That is, is the file that you are reading from readily available every time you start the program or could the initial file vanish and what are the consequences if the file isn't there at start up.

Lots of questions, need more info to give a helpful answer.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses
Course of the Month18 days, 18 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question