How to set CacheSizeMax after the constructor of PersistentDictionary has been run?

Jul 20, 2016 at 5:40 PM
Here is my scenario:
I have a code that uses PersistentDictionary() which will cause the database cache to be over 3GB.
After that code is run, I want to set CacheSizeMax to 100MB to force it to dump majority of the cached data.
I do NOT want to dispose the PersistentDictionary() object, because I am going to use this same object 10 minutes later.

The only way I can see about using CacheSizeMax is from the constructor like the following (refer to this related thread https://managedesent.codeplex.com/discussions/644171 for details).
Is there a way to set it after using the dictionary without disposing it?
    DatabaseConfig databaseConfig = new DatabaseConfig()
    {
        CacheSizeMax = 3 * 1024 * 1024 * 1024 / 8192;  // That is 3GB
    };

    var dictionary = new PersistentDictionary<TKey, string>("myfile", databaseConfig);
    // Use dictionary now...
    // How to set CacheSizeMax to 100MB after using the dictionary without disposing it?
Thanks.
Developer
Aug 3, 2016 at 10:54 PM
Try using the Database property.
        /// <summary>
        /// Gets the Database object associated with the dictionary.
        /// Database can be used to control runtime parameters affecting the dictionary's backing database (e.g. database cache size).
        /// See <see cref="DatabaseConfig"/>.
        /// </summary>
        /// <value>
        /// The Database object associated with the dictionary.
        /// Database can be used to control runtime parameters affecting the dictionary's backing database (e.g. database cache size).
        /// See <see cref="DatabaseConfig"/>.
        /// </value>
        public Database Database