Are there any KeyValue stores used by .NET? [closed] - c#

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 1 year ago.
Improve this question
I am looking up keyvalue stores that support C#, but i found that most of them are implemented by Java. Could anybody recommend some to me? It would be super if it is very light-weight, i.e., appearing as a library. thanks!!

Dictionary<key,Value>
http://msdn.microsoft.com/en-us/library/xfhwa508.aspx
KeyValuePair<string, string>
http://msdn.microsoft.com/en-us/library/5tbh8a42.aspx

If you want an in-process, persistent key-value store (like Berkeley Db) then take a look at the PersistentDictionary which is part of the ManagedEsent project. A persistent dictionary looks like a normal dictionary but is backed by a database. If you build from the current sources then you will get Linq support, which lets you do queries.

If you mean a NoSQL store, What NoSQL solutions are out there for .NET? has a list of these.

There are tons, depending on your requirements.
Another you can consider is System.Runtime.Caching namespace, which has been added to .NET 4.0.

is this what you mean by a key Value pair..like a hashtable()
Hashtable = ht = new HashTable();
or
Dictionary<double,string> d1 = new Dictionary<double,string>();
or
Dictionary<String,string> d2 = new Dictionary<string,string>();
etc.

> I am looking up keyvalue stores that support C#
If you're looking for a native .NET key value store then try NCache. Its built using C#. There are none other i think.
Its offers much more than just a simple .net key value store. You can stick to just keeping keys and values in it.
Cache cache = NCache.InitializeCache("CacheName");
cache.Add("Key", "Value");
object value = cache.Get("Key");

Redis is a excellent one. And there is amazing c# redis client ServiceStackRedis also available. Its very lightweight.
And if you want to try redis on windows, you can find the windows version here

GetCache is a very simple key-value in-memory cache developed in .Net 4.5.
Server and client library can be downloaded fron Nuget.
http://www.nuget.org/packages/GetCacheServer/
http://www.nuget.org/packages/GetCacheClient/

FASTER - A fast concurrent persistent key-value store and log, in C# and C++
https://microsoft.github.io/FASTER/

Related

How to load data from mysql db on start up .Net Core Web API service application? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 26 days ago.
Improve this question
I am new to .Net Core and MySql.
I am trying to develop an service application which would provides multiple types of data to other applications via REST api call using .Net Core and MySql.
I am not able to figure out how to load all the data at start of the application, so that when api calls are triggered, the response can be generated with the data already loaded in the application instead of fetching it from database for each request.
Please suggest an efficient way to achieve this.
I would solve it by using a class that handles the connection to the database and then you have methods for each way you want to access data. Then on the first fetch you collect the data you need from the database and then cache it for the next call. That way you don't need to keep everything in memory if you don't need it.
But if you really need full speed preloading (if possible) is the way to go. Then it depends much of how your data i structured. I would probably load all data into classes so they are already in the correct format and then use a dictionary with the appropriate keys to get the data out of the dictionary. The problem will be if it will be possible to get data in many different ways. If you have database with persons you could create a Person class with all the information about the person and then use the email as the unique identifier so when your other application want all info of a Person by using email a dictionary will be superfast. But if you also want to get all persons in a city or with a specific first name the dictionary will be slow since you will have to loop through all items to look for the city or name.
I would put in my time on how all the searches will be and if you have an id as a unique identifier of a person you could use that in the dictionary and then use a seperate dictionary for each search. So one dictionary where the key is the email and the value points to the unique id in the dictionary with all users. And then another dictionary for cities where the dictionary contains a list of all ids of persons in that city and so forth. In this way you are creating a kind of index like the database uses to fetch data fast.
But it really depends on your data. Is it very complex. Are there a lot of items in the database? Are there a lot of tables which will have there own searches? Can you search for the items in many ways? Will it be allowed to search using wildcards?
The problem is that you are trying to create a temporary in-memory database using the real database as a starting point. And it's not possible to ask someone which is the most efficient way to create a database. To be able to answer that you will need more info.
If you need even more speed you could also pre-serialize all responses and keep them as strings so you can send json (or which format you now will use) straight away. The problem is the more speed you need the more "ugly" the code will get and you will pay for it in memory consumption.

C# checking if a word is in an English dictionary? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I am trying to go through a list of words and for each one determine if it is a valid English word (for Scrabble). I'm not sure how to approach this, do I have to go find a text file of all English words and then use file reading and parsing methods to manually build a data structure like a trie or hashmap - or can I find those premade somewhere? What is the simplest way to go about this?
You can use NetSpell library for checking this. It can be installed through Nuget Console easily with the following command
PM> Install-Package NetSpell
Then, loop through the words and check them using the library
NetSpell.SpellChecker.Dictionary.WordDictionary oDict = new NetSpell.SpellChecker.Dictionary.WordDictionary();
oDict.DictionaryFile = "en-US.dic";
oDict.Initialize();
string wordToCheck = "door";
NetSpell.SpellChecker.Spelling oSpell = new NetSpell.SpellChecker.Spelling();
oSpell.Dictionary = oDict;
if(!oSpell.TestWord(wordToCheck))
{
//Word does not exist in dictionary
...
}
Since you're looking specifically for valid Scrabble words, there are a few APIs that validate words for Scrabble. If you use anything that's not for that intended purpose then it's likely going to leave out some words that are valid.
Here's one, here's another, and here's a separate question that lists available APIs.
So that I can add some value beyond just pasting links, I'd recommend wrapping this in your own interface so that you can swap these out in case one or another is unavailable (since they're all free services.)
public interface IScrabbleWordValidator
{
bool IsValidScrabbleWord(string word);
}
Make sure your code only depends on that interface, and then write implementations of it that call whatever APIs you use.

Extracting frames of a .avi file [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 8 years ago.
Improve this question
I am trying to write a c# code to extract each frame of a .avi file and save it into a provided directory. Do you know any suitable library to use for such purpose?
Note: The final release must work on all systems regardless of installed codec, or system architecture. It must not require the presence of another program (like MATLAB) on the machine.
Thanks in advance.
Tunc
This is not possible, unless you add some restrictions to your input avi files or have control over encoder used to create them. To get an image you will have to decode it first, and for that you will need an appropriate codec installed or deployed with your app. And i doubt its possible to account for every codec out there or install/deploy them all. So no, you won't be able to open just any avi file. You can, however, support the most popular (or common in your context) codecs.
The easiest way to do it is indeed using an FFMPEG, since its alredy includes some of the most common codecs (if you dont mind extra 30+Mb added to your app). As for wrappers, i used AForge wrapper in the past and really liked it, because of how simple it is to work with. Here is an example from its docs:
// create instance of video reader
VideoFileReader reader = new VideoFileReader( );
// open video file
reader.Open( "test.avi" );
// read 100 video frames out of it
for ( int i = 0; i < 100; i++ )
{
Bitmap videoFrame = reader.ReadVideoFrame( );
videoFrame.Save(i + ".bmp")
// dispose the frame when it is no longer required
videoFrame.Dispose( );
}
reader.Close( );
There is also a VfW (which is included in Windows by default) wrapper in AForge, if you want to keep it simple without involving external libraries. You will still need VfW compatible codecs installed tho (some of them are included in Windows by default, most are not).
You could have a look at FFmpeg: http://www.ffmpeg.org/
Some C# related info: Using FFmpeg in .net?
or: http://www.ffmpeg-csharp.com/

Is there any framework for .NET to populate test data? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 3 years ago.
Improve this question
I am use c# and for unit testing and integration testing usually I need to populate fields automatically based on attributes.
Lets say we will test if we can write and get back user data to database.
I create a user object populate fields write user to database
Read user object from database
Check fields if what I write is same as what I read
Is there any framework to populate user with test data automatically and check if two object are have the same values?
Sample code may like this
User user = new User();
AutoPopulator.Populate(user);
user.Save();
You might find it relevant. Here is a list of few other frameworks as of today:
Well-known and respected:
NBuilder
AutoFixture
AutoPoco(Discontinued / Deprecated)
Bogus - C# port of faker.js with locale support. Used by Elasticsearch (NEST).
Little-known:
Hydrator
Fabricator
Unfamiliar:
TestDataGenerator
TestDataFactory (Discontinued)
TestData
Any-.Net
Take a look at NBuilder. It lets you build test objects with random data, incrementing values, and anything you can probably think of. All through a nice fluent interface.
Yes there is. I found this when watching session #3 of the Summer of NHibernate series by Stephen Bohlen.
His company, Microdesk, has developed a utility that will allow you to save the state of a database on test fixture construction, set the state of the database at the start of every test, and recover the original state of the database on test fixture deconstruction.
Download the utility here: Microdesk.Utility.UnitTest
For a tutorial on how to use it, watch the Summer of NHibernate session #3 video.
Fluent NHibernate has a feature which gives you everything on your wish-list, except the auto-population part:
Link: http://wiki.fluentnhibernate.org/Persistence_specification_testing
However, given C# with code contracts, it wouldn't be to hard to auto-magically create valid objects yourself using reflection.

I want to know more about LinkedList<T> [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
I'm learning c# , and I reached the LinkedList<T> type and I still need to know more, like when should I use it, how do I create one, how do I to use it. I just want information.
If any one knows a good article about this subject, or if you can show me some examples with explanation, such as how to create, how to add and remove, and how to deal with nodes and elements.
Thanks in advance. I really enjoy asking questions around here with all the pros answering and helping.
[EDIT] Changed reference to LinkedList<T> instead of "array linkedlist." I think this was what was meant based on the context.
You can find more information on LinkedList<T> at MSDN, including an example of how to create and use one. Wikipedia has a reasonable article on linked lists, including their history, usage, and some implementation details.
Linked is a collection to store sequences of values of the same type, which is a frequent task, e.g. to represent a queue of cars waiting at a stoplight.
There are many different collection types like linked list, array, map, set etc. Which one to use when depends on their properties, e.g.:
do you need some type of ordering?
is the container associative, storing key-value pairs like a dictionary?
can you store the same element twice?
performance measures - how fast is e.g. inserting, removing, finding an element? This is usually given in Big-O notation, telling you how the time required scales with the number of elements in the collection.
Memory footprint and layout. This also can affect performance, due to good/bad locality.
This collection class implements a doubly linked list. It allows you to quickly determine the immediate sibling for a specified item in the collection. Removing an item from the collection automatically resizes it so that it does not leave any gaps.
For more info on LinkedList class, check out LinkedList at MSDN.
Do you know what a standard Linked List is? It's like one of those (doubly linked) but using .NET Generics to allow you to easily store any Type inside of it.
Honestly, I don't use it, I prefer the more basic List or Dictionary.
For more info on Linked Lists, check out wikipedia. As for generics, there are tons of articles here and at MSDN.
linklist are collections.. they can be use as replacements for arrays.. they can dynamically grow in size and has special helper methods that can help the development or the problem solving be faster.. try to view its methods and properties to understand more.
linklist is a generic collection.. meaning can used to declare type safety declarations..

Categories