Memcached Session Storage
Memcached Session Storage support, or the more useful repcached version (see below) provides a high-performance method for sharing state between multiple nodes. Note, however, since Memcached is a storage mechanism, it should not be used for long term storage. Memcached is used on such high profile sites as eBay, Facebook, etc.
Configuration
Memcached, like the In-Memory ticket storage, requires you to add dependencies for the protocols you wish to support. To deploy the memcached session storage mechanism, you would need to include at least one protocol in your web application's pom.xml
<dependency> <group>org.jasig.cas.server</group> <artifactId>cas-server-protocol-cas-sessionstorage-memcached</artifactId> <version>${cas.version}</version> <type>jar</type> <scope>runtime</scope> </dependency>
Replace the version with the proper version of CAS. This will enable the CAS protocol with the default settings. You need to add dependencies for each protocol you wish to enable in CAS4.
Unlike the In-Memory version, however, the memcached ticket storage mechanism requires some Spring configuration. Under your web applications WEB-INF/spring directory, create a new XML file similar to the one below:
<?xml version="1.0" encoding="UTF-8"?> <!-- Copyright (C) 2009 Jasig, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"> <bean id="memcachedSessionStorage" class="org.jasig.cas.server.session.MemcachedSessionStorageImpl"> <constructor-arg index="0"> <list> <bean class="org.jasig.cas.server.session.MemcachedSessionImplFactory" /> </list> </constructor-arg> <constructor-arg index="1"> <list> <value>localhost:11211</value> </list> </constructor-arg> <constructor-arg index="2" value="3600" /> </bean> </beans>
You'll need to replace "localhost:11211" with your memcached server and port. The "3600" should be the time, in seconds, you've set your sessions to last. This lets memcached know when it can clean them out.
Security
As always, you should discuss with your Network team on the best way to secure the data being sent to the memcache servers. Memcache does not encrypt information so you need to protect it on your own.
Repcached
Memcached is literally a cache and does not failover/replication/etc. by default. At Rutgers, we've tested a patch called repcache that adds this functionality. There are some limitations to repcache (i.e. the number of servers you can replicate to), but it appears to work well in our testing. We'll update this with any information.