Because it uses ESE (Extensible Storage Engine, available on Windows since 2000) database for storage. PersistentDictionary can store much more objects than Dictionary when storing large number items. However, PersistentDictionary has some restrictions as well as performance behavior which users should take precaution when using it. Below is some of these that i came across when using this class.
- Key in PersistentDictionary must implement IComparable<T> interface
- Key in PersistentDictionary must not be a struct, should be a class or valuetype
- Value in PersisentDictionary must a system valuetype or a struct that implements a System.Serializable attribute. It is not straight forward to use any class as the value in PersistentDictionary (even if it implements Serializable or DataContract interface), if it is so desired that the value should be a class then refers to the DemoDictionary in the above link
- The Clear() method in PersistentDictionary is very tricky to use, it almost throttled my program when it is called. My recommendation is that don't use Clear() method. Instead i used the "new PersistentDictionary<KeyType, ValueType>("[dictionary_name]")" to reassign the object. This solved the problem, at least in my case.
- When creating a PersistentDictionary, do note that the constructor "new PersistentDictionary<KeyType, ValueType>("[dictionary_name]")" will invoke from the ESE database in the directory [dictionary_name], therefore if the PersistentDictionary is created previously, and new content is to be generated for the same PersistentDictionary when the constructor is called, then the user should call the PersistentDictionaryFile.Exists([dictionary_name]) to check whether cache file is already generated and call PersistentDictionaryFile.Delete([dictionary_name]) to delete the cache files previously generated for the same dictionary object (also remember to dispose the PersistentDictionaryObject first before calling Delete method as otherwise ESENT will have the database of the corresponding object open until the instance is finalized).