Git Product home page Git Product logo

simple-spring-memcached's Introduction

Simple Spring Memcached

A drop-in library to enable memcached caching in Spring beans via annotations.

Source code and issue tracking are available on github, documentation is on google code but soon it will be migrated here.

Introduction

Distributed caching can be a big, hairy, intricate, and complex proposition when using it extensively.

Simple Spring Memcached (SSM) attempts to simplify implementation for several basic use cases.

(15-06-2014) New version 3.5.0 with Amazon ElastiCache support is available! Since version 3.0.0 it can work as a cache back-end in Spring Cache (@Cacheable). Please check release notes.

This project enables caching in Spring-managed beans, by using Java 5 Annotations and Spring/AspectJ AOP on top of the spymemcached, xmemcached or aws-elasticache client. Using Simple Spring Memcached requires only a little bit of configuration and the addition of some specific annotations on the methods whose output or input is being cached.

Usage

If you are using maven, you can try it now:

<dependencies>
   <dependency>
     <groupId>com.google.code.simple-spring-memcached</groupId>
     <artifactId>xmemcached-provider</artifactId>
     <version>3.5.0</version>
   </dependency> 
</dependencies>

and define connection to memcached on localhost:

<beans xmlns="http://www.springframework.org/schema/beans" 
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/aop
        http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">

  <import resource="simplesm-context.xml" />
  <aop:aspectj-autoproxy />

  <bean name="defaultMemcachedClient" class="com.google.code.ssm.CacheFactory">
      <property name="cacheClientFactory">
            <bean class="com.google.code.ssm.providers.xmemcached.MemcacheClientFactoryImpl" />
      </property>
      <property name="addressProvider">
            <bean class="com.google.code.ssm.config.DefaultAddressProvider">
                 <property name="address" value="127.0.0.1:11211" />
            </bean>
      </property>
      <property name="configuration">
            <bean class="com.google.code.ssm.providers.CacheConfiguration">
                  <property name="consistentHashing" value="true" />
            </bean>
      </property>
   </bean>
</beans>

Now you can annotate method to cache result:

@ReadThroughSingleCache(namespace = "CplxObj", expiration = 3600)
public ComplexObject getComplexObjectFromDB(@ParameterValueKeyProvider Long complexObjectPk) {
  // ...
  return result;
}

If you already using Spring Cache you may use SSM as an another back-end.

Need more? Please read getting started guide.

Contact Us

If you have any questions, feel free to ask them on the Google Group. (UPDATE: Sorry, this link was bad up until 02 Aug '09, because I fat-fingered when creating the Google Group. I incorrectly misspelled it as 'simple-spring-memEcached'. So sorry about that!)

Also, let us know if you are using SSM in your project, and we will list it in on the Wiki.

simple-spring-memcached's People

Contributors

ragnor avatar nelz9999 avatar

Watchers

James Cloos avatar crop avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.