Skip to content
This repository

The configuration of the Membase client is similar to the basic MemcacedClient's. You have two options

  • using the app.config,
  • providing an object which implements IMembaseClientConfiguration

App.config

This is a full configuration file:

    <configuration>
      <configSections>
        <section name="membase" type="Membase.Configuration.MembaseClientSection, Membase" />
      </configSections>

      <membase>
        <servers bucket="bucket name" bucketPassword="bucket password" retryCount="integer" retryTimeout="timespan">
          <add uri="pool url" />
          <add uri="pool url" />
        </servers>
        <socketPool minPoolSize="integer" maxPoolSize="integer" connectionTimeout="timespan" deadTimeout="timespan"/>
        <locator type="fully qualified type name" factory="fully qualified type name" />
        <transcoder type="fully qualified type name" factory="fully qualified type name" />
        <keyTransformer type="fully qualified type name" factory="fully qualified type name" />
      </membase>
    </configuration>

All elements are optional except where specified.

membase

This section is used as default, if no other config is provided to the client.

membase/servers (required)

This element is used to specify the pool urls which will provide the configuration data. Define as many servers as possible to have fallback urls in case some of them stops working.

Urls are usually in the form http://HOST:8091/pools/default but you should copy the host and port from the url of the Membase web console. Makes sure you keep the /pools/default at the end of the url!

  • bucketName: Specify which bucket this configuration should use. If not specified the client will use the default bucket.
  • bucketPassword: Membase supports custom passwords per buckets, which should be specified here. Do not define this attribute, if the bucket has no password. (Leaving it empty works too. bucketPassword="")
  • retryCount (optional, 0): The client needs to have a persistent HTTP connection to the cluster controller to get notified about the changes. When this connection is closed, the client treats this controller node as 'down'. However some load balancers (especially Amazon EC2) closes idle connections after a period of time, thus messing up the dead node detection of the client. retryCount instructs the client to reconnect to the node N times before giving up and treating the node as not working.
  • retryTimeout (optional, 00:00:00.500): Specifies the interval between connection attempts to the controller node. (Note: operations are not retried, this value is used with the retryCount only.)

Note: it is not recommended to store plain text passwords in configuration files, you should always encrypt them.
Note 2: The bucketPassword had a different behavior in older versions. (When it was set to null the client used the name of the bucket.) As of 2.11 bucket passwords must be explicitly set.

membase/socketPool

Same as the MemcachedClient's socketPool configuration: defines how the client should handle the connections to the servers.

  • minPoolSize (optional, 10): The minimum number of connections opened to each Membase server.
  • maxPoolSize (optional, 20): The maximum number of connections that can be opened to each Membase server.
  • connectionTimeout (optional, 00:00:10): The amount of time the client is waiting to a) eastablish a connection to the memcached server, b) get a free connection from the pool. If it times out the operation will fail. (And return false or null, depending on the operation.)
  • deadTimeout (optional, 00:00:10): When all pool urls are unavailable the client will check the first one again after deadTimeout time elapses. Additionally, the client has a basic dead node detection mechanism which will also use this timeout to reconnect servers which went offline.

Note: Usually you only need to add the server urls and set the bucket name & password. The other values have sane defaults.
Note 2: maxPoolSize's default value was 100 in 2.10 and below. Until you can upgrade it's recommended to manually set it to a lower value.

See also memcached/socketPool for more details.

membase/locator

Used to map objects to servers in the pool. Either type or factory must be provided (factory takes precedence if both are specified).

  • type must be the fully qualified name of a Type implementing IMemcachedNodeLocator
  • factory must be the fully qualified name of a Type implementing IProviderFactory<IMemcachedNodeLocator>

For more information, see IProviderFactory.

membase/keyTransformer

Used to normalize/validate the item keys before sending them to the server. Either type or factory must be provided (factory takes precedence if both are specified).

  • type must be the fully qualified name of a Type implementing IMemcachedKeyTransformer
  • factory must be the fully qualified name of a Type implementing IProviderFactory<IMemcachedKeyTransformer>

For more information, see IProviderFactory.

membase/transcoder

Used to serialize stored/retrieved objects. Either type or factory must be provided (factory takes precedence if both are specified).

  • type must be the fully qualified name of a Type implementing ITranscoder
  • factory must be the fully qualified name of a Type implementing IProviderFactory<ITranscoder>

For more information, see IProviderFactory.

IMembaseClientConfiguration

You should implement this interface if you want to provide your own configuration mechanisms (for example, reading the config from the database), or you just need more flexibility.

There is a default implementation included: Membase.Configuration.MembaseClientConfiguration. Its properties correspond with the attributes above.

Something went wrong with that request. Please try again.