DATAREDIS-68
+ add docs on Spring Cache implementation for Redis
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
<section id="get-started:first-steps">
|
||||
<title>First Steps</title>
|
||||
|
||||
<para>As explained in <xref linkend="why-sdr"/>, Spring Data Redis (SDR) provides integration
|
||||
<para>As explained in <xref linkend="why-spring-redis"/>, Spring Data Redis (SDR) provides integration
|
||||
between Spring framework and the Redis key value store. Thus, it is important to become acquainted with both of these
|
||||
frameworks (storages or environments depending on how you want to name them). Throughout the SDR documentation,
|
||||
each section provides links to resources relevant however, it is best to become familiar with these topics beforehand.</para>
|
||||
@@ -39,36 +39,12 @@
|
||||
</section>
|
||||
<section id="get-started:first-steps:samples">
|
||||
<title>Trying Out The Samples</title>
|
||||
<para>Unfortunately the SDKV project is very young and there are no samples available yet. However we are working on them and plan to make them available
|
||||
as soon as possible. In the meantime however, one can use our test suite as a code example (assuming the documentation is not enough) - we provide extensive
|
||||
integration tests for our code base.
|
||||
</para>
|
||||
<!--
|
||||
<para>The current distribution contains:</para>
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>Simple Service Sample</para>
|
||||
<para>A simple example that illustrates OSGi service publication and consumption through Spring DM. This is a good starting point
|
||||
for users learning the basics.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Weather Sample</para>
|
||||
<para>A demo that shows more advanced features of Spring DM and OSGi. The application creates a very simple weather information services
|
||||
presenting some best practices in designing an application to take advantage of the modularity offered by OSGi.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Simple Web App Sample</para>
|
||||
<para>As the name implies, this is a simple web application, containing Servlets, JSPs and JSP tags, that runs inside OSGi through Spring DM.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Web Console Sample</para>
|
||||
<para>A more complicated sample that demos a Spring MVC annotation based, web application that runs inside OSGi through Spring DM, featuring
|
||||
class path scanning and various Spring taglib. Additionally, the web application interacts with the OSGi environment through the web UI.</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
<para>Each project contains instructions regarding its content and startup procedure. Users are encouraged to experiment with the samples to get a better
|
||||
understanding of the technologies used.</para>
|
||||
-->
|
||||
<para>One can find various samples for key value stores in the dedicated example repo, at
|
||||
<ulink url="https://github.com/SpringSource/spring-data-keyvalue-examples">http://github.com/SpringSource/spring-data-keyvalue-examples</ulink>. For Spring Redis,
|
||||
of interest is the <literal>retwisj</literal> sample, a Twitter-clone built on top of Redis which can be run locally or be deployed into the cloud. See its
|
||||
<ulink url="http://static.springsource.org/spring-data/data-keyvalue/examples/retwisj/current/">documentation</ulink>, the following blog
|
||||
<ulink url="http://blog.springsource.com/2011/04/27/getting-started-redis-spring-cloud-foundry/">entry</ulink> or the
|
||||
<ulink url="http://retwisj.cloudfoundry.com/">live instance</ulink> for more information.</para>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
|
||||
@@ -34,7 +34,8 @@
|
||||
<xref linkend="redis:template"/> explains the abstraction builds on top of the low-level <interfacename>Connection</interfacename> API to handle the
|
||||
infrastructural concerns and object conversion.</listitem>
|
||||
<listitem><emphasis>Support Classes</emphasis> - that offer reusable components (built on the aforementioned abstractions) such as
|
||||
<interfacename>java.util.Collection</interfacename> backed by Redis as documented in <xref linkend="redis:support"/></listitem>
|
||||
<interfacename>java.util.Collection</interfacename> or Spring 3.1 <ulink url="http://blog.springsource.com/2011/02/23/spring-3-1-m1-caching/">cache</ulink> implementation backed by
|
||||
Redis as documented in <xref linkend="redis:support"/></listitem>
|
||||
</itemizedlist>
|
||||
|
||||
<para>For most tasks, the high-level abstractions and support services are the best choice. Note that at any point, one can move between layers - for example, it's very
|
||||
@@ -404,6 +405,28 @@
|
||||
|
||||
<para>As shown in the example above, the consuming code is decoupled from the actual storage implementation - in fact there is no indication that Redis is used underneath. This makes moving from
|
||||
development to production environments transparent and highly increases testability (the Redis implementation can just as well be replaced with an in-memory one).</para>
|
||||
|
||||
<section id="redis:support:cache-abstraction">
|
||||
<title>Support for Spring Cache Abstraction</title>
|
||||
|
||||
<para>Spring Redis provides an implementation for Spring 3.1 <ulink url="http://static.springsource.org/spring/docs/3.1.0.M2/spring-framework-reference/html/cache.html">cache abstraction</ulink>
|
||||
through the <literal>org.springframework.data.redis.cache</literal> package. To use Redis as a backing implementation, simply add <literal>RedisCacheManager</literal> to your configuration:</para>
|
||||
|
||||
<programlisting language="xml"><![CDATA[<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:cache="http://www.springframework.org/schema/cache"
|
||||
xmlns:c="http://www.springframework.org/schema/c"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache.xsd">
|
||||
<!-- turn on declarative caching -->
|
||||
<cache:annotation-driven />
|
||||
|
||||
<!-- declare Redis Cache Manager -->
|
||||
<bean id="cacheManager" class="org.springframework.data.redis.cache.RedisCacheManager" c:template-ref="gemfire-cache">
|
||||
</beans>]]>
|
||||
|
||||
</programlisting>
|
||||
</section>
|
||||
|
||||
</section>
|
||||
|
||||
<section id="redis:future">
|
||||
|
||||
Reference in New Issue
Block a user