Skip to main content
Skip table of contents

Configure Couchbase Memory Persistent Cache - SuperWEB2

To use the Couchbase Memory Persistent Cache strategy with SuperWEB2 you need to complete the following steps:


Step 1 - Download and Install Couchbase

  1. Download Couchbase Community Edition 1.8.0 from http://www.couchbase.com/download
  2. Run couchbase-server-community_x86_64_1.8.0.setup.exe, following the instructions in the installation wizard.

  3. When you are asked for the port number, enter 8091

  4. When the installer completes, a web browser window will open and load http://localhost:8091/index.html

  5. Follow the instructions in the wizard to configure Couchbase.

  6. When you are asked whether to Start a new cluster or Join a cluster now, choose Start a new Cluster.

  7. Leave the recommended Per Server Ram Quota as it is. This is the maximum amount of memory Couchbase can use for all data buckets.

    Couchbase provides monitoring tools which will help you track the memory usage.

  8. When you are asked for the type of server, choose MemCached.

  9. You will then need to create a default bucket. Start with a bucket smaller than the Per Server RAM Quota. For example if the Per Server RAM Quota is 4663 MB, try 1024 MB.


    You will be able to create more buckets up to the maximum size of the Per Server RAM Quota.

  10. When the Notifications screen displays, click Next.
  11. When the Configure Server screen displays, enter a username and password for the new Administrator account and click Next.
  12. Then a Couchbase dashboard will be displayed with monitoring tools.
  13. Click Data Buckets in the left side menu, then click Create New Data Bucket on top right.

    A new window displays.
  14. In the Bucket Name field, enter superweb2cache
  15. In the Bucket Type, select Couchbase
  16. In Access Control, select Standard port and enter a password (you will need this password when you configure web.xml in the next step).
  17. In Per Node RAM Quota, enter 512 MB for the memory size or any other size suitable for your caching needs for SuperWEB2. You can adjust the memory size later during runtime without loss of data and server restart.
  18. If there is only one server node, clear the Enable Replication check box.
  19. Click Create.

Step 2 - Configure web.xml

Once you have installed and configured Couchbase, you need to configure the following parameters in the web.xml configuration file. This file is located in <tomcat_home>\webapps\webapi\WEB-INF\

ParameterConfiguresSet To
memCachedServerExpirationThe cache expiration time in seconds. The default value is 0 which means no expiration. 0
memCachedServerURLThe full URL to the Couchbase memcache server. The URL, e.g. http://localhost:8091/pools
couchbaseBucketNameThe bucket name configured in Couchbase server to use as the SuperWEB2 cache.The bucket name you selected during configuration.

couchbaseBucketPassword

The password used to access the Couchbase bucket.The password you selected during configuration.
lruMapSize

The size of the in-memory Least Recently Used map for storing table query results.

You may wish to change this setting because the CouchBaseMemoryPersistentCache strategy uses LRUMap caching in addition to the cache stored in Couchbase. By default, it stores a maximum of 30 table query results. Please be aware that the bigger this number, the more memory you should allocate to Tomcat using the JVM options -Xmx.

The number of table queries to store in memory. The default value is 30.
systemTableCacheStrategy

The cache strategy for system defined tables stored in webapi\WEB-INF\resources\txd.

CouchBaseMemoryPersistentCache

otherTableCacheStrategyThe cache strategy for non-system defined tables.

One of the following:

  • CouchBaseMemoryPersistentCache
  • LRUMemoryCache
  • NoCache

 

  1. Open web.xml in a text editor.

    Make a backup copy of this file before making any changes.

  2. Search for the Query Caching section:

    CODE
    <!-- Query Caching Configuration  -->
        <!-- 0 means never expire -->
        <context-param>
        	<description>MemCached Server Cache Expiration Period</description>
        	<param-name>memCachedServerExpiration</param-name>
        	<param-value>0</param-value>
        </context-param>
        <context-param>
        	<description>MemCached Server URL</description>
        	<param-name>memCachedServerURL</param-name>
        	<param-value>http://localhost:8091/pools</param-value>
        </context-param>        
        <!-- "default" is the default bucketname when using with memcached bucket type -->
        <context-param>
             <description>Couchbase Server bucket name</description>
             <param-name>couchbaseBucketName</param-name>
             <param-value>superweb2cache</param-value>
        </context-param>
        <!-- Empty if no specified during Couchbase server configuration -->
        <context-param>
              <description>Couchbase Server bucket password</description>
              <param-name>couchbaseBucketPassword</param-name>
              <param-value>superweb2cache</param-value>
        </context-param>       
        <context-param>    	
            <description>In-memory cache LRUMap size</description>
        	<param-name>lruMapSize</param-name>
        	<param-value>30</param-value>
        </context-param>
        <!-- Available cache strategy options: 
        	CouchBaseMemoryPersistentCache - Couchbase MemCached persistent cache would be used.
        					 Required params: memCachedServerExpiration, memCachedServerURL, lruMapSize
        	LRUMemoryCache - In-memory LRU cache would be used.
        		 	 Required params: lruMapSize
        	NoCache - No caching would be used.
        -->
        <context-param>
        	<description>System Table Cache Strategy</description>
        	<param-name>systemTableCacheStrategy</param-name>
        	<param-value>NoCache</param-value>
        </context-param>    
        <context-param>
        	<description>Cache Strategy for rest of tables</description>
        	<param-name>otherTableCacheStrategy</param-name>
        	<param-value>NoCache</param-value>
        </context-param>
  3. Set memCachedServerURL to the full URL of the Couchbase server. If you selected the default options, the URL should be http://localhost:8091/pools

  4. Leave memCachedServerExpiration set to 0.
  5. Set couchbaseBucketName  to the Bucket Name you specified when you configured Couchbase.
  6. Set couchbaseBucketPasswordto the password you set when you configured Couchbase.
  7. Set lruMapSize to the number of table query results you want to cache in memory.
  8. Set systemTableCacheStrategy to CouchBaseMemoryPersistentCache.
  9. Set otherTableCacheStrategy to CouchBaseMemoryPersistentCache if you want to use CouchBaseMemoryPersistentCache for all kinds of table query including saved tables and ad-hoc created tables.

We recommend using LRUMemoryCache or NoCache for non-system tables as they are not commonly used tables and will require more memory which might jeopardise the performance of SuperWEB2 if insufficient memory is given to the machine.

 

 

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.