NCache 4.3 - Online Documentation

Gateway Support

There are two deployments of Memcached gateway of NCache.
1.     Memcached client side gateway: The Gateway Server runs on NCache remote clients:
2.     Memcached Server side gateway: The Gateway Server runs on NCache servers:
The following diagrams illustrate these deployments.
Figure 1: Memcached Gateway Server running on NCache remote client machines
In the above diagram, you can see that the Memcached gateway server (also called Memcached Client Wrapper) runs on NCache remote clients (Memcached application servers). The Memcached client application talks to this gateway as if it is a Memcached server. And, gateway
then in turn talks to the NCache cluster using NCache API calls. Gateway is implemented based on Memcached socket protocol and understands
all Memcached client requests. It intercepts Memcached commands and then in turn executes NCache APIs equivalent to these commands on
NCache distributed cache.
Using Memcached Gateway server:
NCache’s Memcached gateway server comes installed in NCache server installation as well as with NCache remote client installation.
Configurations are same for both deployments.  It is only required in configurations to specify address of either remote client or cache server to
be the Memcached gateway. 
Configuring NCache Memcached Gateway Server
NCache installation on cache server and client box will install a windows service named NCache Memcached Gateway service. This service is the
actual NCache client and will serve as gateway for all client requests to be routed to NCache. You can use either client getaway deployment or
NCache server side gateway deployment as mentioned earlier.
Step1: Configure NCache Memcached Gateway Service:
·     Open “Alachisoft.NCache.Memcached.exe.config” file from “%NCache Install Directory%\integration\Memcached\Gateway” on remote client
machine or cache server where you want to run your Gateway server.
It contains information on IP addresses and ports where it is listening to receive Memcached client requests and also target cache name where it
is going to route these requests.
·     You need to provide target cache name and also setup gateway IP and Port for receiving client requests. You will need to change application
configs to talk to this service later on.
<?xml version="1.0"?>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
    <add key="CacheName" value="mycache"/>
    <add key="TextProtocolIP" value=""/>
    <add key="TextProtocolPort" value="11212"/>
    <add key="BinaryProtocolIP" value=""/>
    <add key="BinaryProtocolPort" value="11213"/>
    <!--Maximum command length in KBs-->
    <add key="MaxCommandLength" value="200"/>
Here are details on configurations.
CacheName: Name of clustered cache on which all of your operations from Memcached end user applications are going to be performed via
NCache Memcached gateway service
TextProtocolIP, TextProtocolPort : IP and port where gateway service will run and listen to all client requests for applications using Text protocol
of Memcached. Here you can specify either remote client address or cache server address depending upon client gateway and server gateway deployments respectively. 
BinaryProtocolIP , BinaryProtocolPort : IP and port where gateway service will run and listen all client requests for applications using Binary
protocol of Memcached.
MaxCommandLength : Specifies the maximum length of command in KBs for gateway server Text protocol.
Step2: Start Memcached Gateway Server
·     Start NCache Memcached Gateway service from windows services. NCache Memcached Gateway Service is not set to automatic by default.
You must start the service manually at first and can change startup option to “Automatic” later on.
Configuring Memcached client application to use Gateway Server:
You now need to specify NCache Memcached Gateway server (IP address and port) instead of actual Memcached server in client applications so
that applications talk to gateway and then gateway in turn talks to cache.
Step1: specify NCache Memcached Gateway server in client applications:
Here you need to specify NCache Memcached Gateway server (IP address and port) instead of actual Memcached server in client applications.
Here is a sample configuration for a popular Memcached client (enyim) which is using default Memcached server settings.
<?xml version="1.0" encoding="utf-8" ?>
    <sectionGroup name="">
      <section name="Memcached" type="Enyim.Caching.Configuration.MemcachedClientSection, Enyim.Caching" />
    <Memcached protocol="Text">
        <add address="" port="11211" />
      <socketPool minPoolSize="10" maxPoolSize="20" connectionTimeout="00:00:10" deadTimeout="00:00:10" />
Highlighted part is changed as follows replacing only NCache gateway server settings for Text and binary protocol.
    <Memcached protocol="Text">
        <add address="" port="11212" />
      <socketPool minPoolSize="10" maxPoolSize="20" connectionTimeout="00:00:10" deadTimeout="00:00:10" />
If you are specifying IP address and port in the code instead of config files then it needs to be changed their accordingly.
Step2: Run your application to use Gateway
Run your application and verify that operations are being performed through your applications on the specified cluster by viewing NCache statistics
of cluster in NCache Manager.
See Also

© Copyright  2014 Alachisoft. All rights reserved.