app.config

Nov 18, 2011 at 8:42 AM

I have looked everywhere but am unable to find any documentation on how to use the nmemcached.client Config section. It should be easy but haven't been able to get it working.

I figured the app.config should look something like this:

<?xml version="1.0"?>
<configuration>
  <configSections>
    <section name="nmemcached.client" type="NMemcached.Client.Configuration.ConfigSection" allowLocation="true" allowDefinition="Everywhere"/>
  </configSections>

  <nmemcached.client>
    <add server="192.168.9.7" port="11211" useCompression="true"/>
  </nmemcached.client>
</configuration>

But then how do I proceed? How do I get a MemcachedClient configured with the values from my app.config?

  1. Is my app.config section correct? If not; where did I go wrong
  2. What would be the correct way tot instantiate a MemcachedClient object?

Thanks for the great project!

Coordinator
Dec 7, 2011 at 4:36 PM
Edited Dec 7, 2011 at 5:02 PM

Sorry for the lengthy delay in the response, I have not been able to check up on this project for a little while.

I am in the process of creating the documentation page for the configuration. For now, here are the changes that need to be made to the configuration above to get it working:

  • The type in the section name should be "NMemcached.Clent.Configuration.NMemcachedConfigurationSection, NMemcached.Client". The client assembly must be specified so the configuration system knows where to find the section handler.
  • The <add /> elements must be within a <connectionProvider> element under the <nmemcached.client> element.

The modified configuration will look like this:

<configSections>
    <section name="nmemcached.client" type="NMemcached.Client.Configuration.NMemcachedConfigurationSection, NMemcached.Client" allowLocation="true" allowDefinition="Everywhere"/>
</configSections>
<nmemcached.client>
  <connectionProvider>
    <add server="192.168.9.7" port="11211" useCompression="true"/>
  </connectionProvider>
</nmemcached.client>

Call the MemcachedClient.Create method to get the client that uses the configuration file.

On a side note, an XSD is in the project that was included specifically for intellisense. Add the XSD to the <VSInstallDirectory>\Xml\Shemas and include xmlns="http://memcached.protectedvoid.com/2011/06/configuration" in the nmemcached.client element.

Dec 14, 2011 at 1:50 PM
Edited Dec 14, 2011 at 7:43 PM

You're my hero! Works like a charm (altough I seem to run into a problem with compression).