{"id":70914,"date":"2017-11-28T13:00:02","date_gmt":"2017-11-28T11:00:02","guid":{"rendered":"https:\/\/www.javacodegeeks.com\/?p=70914"},"modified":"2017-11-27T12:17:01","modified_gmt":"2017-11-27T10:17:01","slug":"intro-redis-spring-boot","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2017\/11\/intro-redis-spring-boot.html","title":{"rendered":"Intro to Redis with Spring Boot"},"content":{"rendered":"<h2>1. Overview<\/h2>\n<p>In this article, we will review the basics of how to use<strong> Redis with Spring Boot<\/strong> through the<strong> Spring Data Redis<\/strong> library.<\/p>\n<p>We will build an application that demonstrates how to perform <strong>CRUD operations Redis<\/strong> through a web interface. The full source code for this project is available on <a href=\"https:\/\/github.com\/michaelcgood\/spring-data-redis-example\" target=\"_blank\" rel=\"noopener\">Github<\/a>.<\/p>\n<h2>2. What is Redis?<\/h2>\n<p>Redis is <a href=\"https:\/\/redis.io\/topics\/introduction\">an open source, in-memory\u00a0key-value data store<\/a>, used as a database, cache and message broker. In terms of implementation, Key Value stores represent one of the largest and oldest members in the NoSQL space. Redis supports data structures such as strings, hashes, lists, sets, and sorted sets with range queries.<\/p>\n<p>The <a href=\"https:\/\/docs.spring.io\/spring-data\/data-redis\/docs\/current\/reference\/html\/\">Spring Data Redis\u00a0 framework<\/a> makes it easy to write Spring applications that use the Redis key value store by providing an abstraction to the data store.<\/p>\n<h2>3. Setting Up A Redis Server<\/h2>\n<p>The server is available for free at\u00a0<a href=\"http:\/\/redis.io\/download\">http:\/\/redis.io\/download<\/a>.<\/p>\n<p>If you use a Mac, you can install it with homebrew:<\/p>\n<pre class=\"brush:bash\">brew install redis<\/pre>\n<p>Then start the server:<\/p>\n<pre class=\"brush:bash\">mikes-MacBook-Air:~ mike$ redis-server\r\n10699:C 23 Nov 08:35:58.306 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo\r\n10699:C 23 Nov 08:35:58.307 # Redis version=4.0.2, bits=64, commit=00000000, modified=0, pid=10699, just started\r\n10699:C 23 Nov 08:35:58.307 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server \/path\/to\/redis.conf\r\n10699:M 23 Nov 08:35:58.309 * Increased maximum number of open files to 10032 (it was originally set to 256).\r\n                _._                                                  \r\n           _.-``__ ''-._                                             \r\n      _.-``    `.  `_.  ''-._           Redis 4.0.2 (00000000\/0) 64 bit\r\n  .-`` .-```.  ```\\\/    _.,_ ''-._                                   \r\n (    '      ,       .-`  | `,    )     Running in standalone mode\r\n |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379\r\n |    `-._   `._    \/     _.-'    |     PID: 10699\r\n  `-._    `-._  `-.\/  _.-'    _.-'                                   \r\n |`-._`-._    `-.__.-'    _.-'_.-'|                                  \r\n |    `-._`-._        _.-'_.-'    |           http:\/\/redis.io        \r\n  `-._    `-._`-.__.-'_.-'    _.-'                                   \r\n |`-._`-._    `-.__.-'    _.-'_.-'|                                  \r\n |    `-._`-._        _.-'_.-'    |                                  \r\n  `-._    `-._`-.__.-'_.-'    _.-'                                   \r\n      `-._    `-.__.-'    _.-'                                       \r\n          `-._        _.-'                                           \r\n              `-.__.-'                                               \r\n\r\n10699:M 23 Nov 08:35:58.312 # Server initialized\r\n10699:M 23 Nov 08:35:58.312 * Ready to accept connections<\/pre>\n<p>&nbsp;<\/p>\n<h2>4. Maven Dependencies<\/h2>\n<p>Let\u2019s declare the necessary dependencies in our <em>pom.xml<\/em> for the example application we are building:<\/p>\n<pre class=\"brush:xml\">&lt;dependency&gt;\r\n\t\t\t&lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;\r\n\t\t\t&lt;artifactId&gt;spring-boot-starter-data-redis&lt;\/artifactId&gt;\r\n\t\t&lt;\/dependency&gt;\r\n\t\t&lt;dependency&gt;\r\n\t\t\t&lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;\r\n\t\t\t&lt;artifactId&gt;spring-boot-starter-thymeleaf&lt;\/artifactId&gt;\r\n\t\t&lt;\/dependency&gt;\r\n\t\t&lt;dependency&gt;\r\n\t\t\t&lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;\r\n\t\t\t&lt;artifactId&gt;spring-boot-starter-web&lt;\/artifactId&gt;\r\n\t\t&lt;\/dependency&gt;<\/pre>\n<p>&nbsp;<\/p>\n<h2>5. Redis Configuration<\/h2>\n<p>We need to connect our application with the Redis server. To establish this connection, we are using <a href=\"https:\/\/github.com\/xetorthio\/jedis\">Jedis<\/a>, a Redis client implementation.<\/p>\n<h3>5.1 Config<\/h3>\n<p>Let\u2019s start with the configuration bean definitions:<\/p>\n<pre class=\"brush:java\">@Bean\r\n    JedisConnectionFactory jedisConnectionFactory() {\r\n        return new JedisConnectionFactory();\r\n    }\r\n\r\n    @Bean\r\n    public RedisTemplate&lt;String, Object&gt; redisTemplate() {\r\n        final RedisTemplate&lt;String, Object&gt; template = new RedisTemplate&lt;String, Object&gt;();\r\n        template.setConnectionFactory(jedisConnectionFactory());\r\n        template.setValueSerializer(new GenericToStringSerializer&lt;Object&gt;(Object.class));\r\n        return template;\r\n    }<\/pre>\n<p>The <em>JedisConnectionFactory<\/em> is made into a bean so we can create a <em>RedisTemplate<\/em> to query data.<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<h3>5.2 Message Publisher<\/h3>\n<p>Following the<a href=\"https:\/\/en.wikipedia.org\/wiki\/SOLID_(object-oriented_design)\"> principles of SOLID<\/a>, we create a <em>MessagePublisher<\/em> interface:<\/p>\n<pre class=\"brush:java\">public interface MessagePublisher {\r\n\r\n    void publish(final String message);\r\n}<\/pre>\n<p>We implement the <em>MessagePublisher<\/em> interface to use the high-level RedisTemplate to publish the message since the RedisTemplate allows arbitrary objects to be passed in as messages:<\/p>\n<pre class=\"brush:java\">@Service\r\npublic class MessagePublisherImpl implements MessagePublisher {\r\n    \r\n    @Autowired\r\n    private RedisTemplate&lt;String, Object&gt; redisTemplate;\r\n    @Autowired\r\n    private ChannelTopic topic;\r\n\r\n    public MessagePublisherImpl() {\r\n    }\r\n\r\n    public MessagePublisherImpl(final RedisTemplate&lt;String, Object&gt; redisTemplate, final ChannelTopic topic) {\r\n        this.redisTemplate = redisTemplate;\r\n        this.topic = topic;\r\n    }\r\n\r\n    public void publish(final String message) {\r\n        redisTemplate.convertAndSend(topic.getTopic(), message);\r\n    }\r\n\r\n}<\/pre>\n<p>We also define this as a bean in <em>RedisConfig<\/em>:<\/p>\n<pre class=\"brush:java\">@Bean\r\n    MessagePublisher redisPublisher() {\r\n        return new MessagePublisherImpl(redisTemplate(), topic());\r\n    }<\/pre>\n<h3>Message Listener<\/h3>\n<p>In order to subscribe to messages, we need to implement the <em>MessageListener<\/em> interface: each time a new message arrives, a callback gets invoked and the user code executed through a method named <em>onMessage<\/em>. This interface gives access to the message, the channel it has been received through, and any pattern used by the subscription to match the channel.<\/p>\n<p>Thus, we create a service class to implement <em>MessageSubscriber<\/em>:<\/p>\n<pre class=\"brush:java\">@Service\r\npublic class MessageSubscriber implements MessageListener {\r\n    \r\n    public static List&lt;String&gt; messageList = new ArrayList&lt;String&gt;();\r\n\r\n    public void onMessage(final Message message, final byte[] pattern) {\r\n        messageList.add(message.toString());\r\n        System.out.println(\"Message received: \" + new String(message.getBody()));\r\n    }\r\n\r\n}<\/pre>\n<p>We add a bean definition to <em>RedisConfig<\/em>:<\/p>\n<pre class=\"brush:java\">@Bean\r\n    MessageListenerAdapter messageListener() {\r\n        return new MessageListenerAdapter(new MessageSubscriber());\r\n    }<\/pre>\n<h2>6. RedisRepository<\/h2>\n<p>Now that we have configured the application to interact with the Redis server, we are going to prepare the application to take example data.<\/p>\n<h3>6.1 Model<\/h3>\n<p>For this example, we defining a <em>Movie<\/em> model with two fields:<\/p>\n<pre class=\"brush:java\">private String id;\r\nprivate String name;\r\n\/\/standard getters and setters<\/pre>\n<h3>6.2 Repository interface<\/h3>\n<p>Unlike other Spring Data projects, <strong>Spring Data Redis does offer any features to build on top of the other Spring Data interfaces<\/strong>. This is odd for us who have experience with the other Spring Data projects.<\/p>\n<p>Often there is no need to write an implementation of a repository interface with Spring Data projects. We simply just interact with the interface. Spring Data JPA provides numerous repository interfaces that can be extended to get features such as CRUD operations, derived queries, and paging.<\/p>\n<p>So, unfortunately, <strong>we need to write our own interface<\/strong> and then define the methods:<\/p>\n<pre class=\"brush:java\">public interface RedisRepository {\r\n\r\n    Map&lt;Object, Object&gt; findAllMovies();\r\n\r\n    void add(Movie movie);\r\n\r\n    void delete(String id);\r\n\r\n    Movie findMovie(String id);\r\n    \r\n}<\/pre>\n<h3>6.3 Repository implementation<\/h3>\n<p>Our implementation class uses\u00a0the\u00a0<em>redisTemplate<\/em>\u00a0defined in our configuration class <em>RedisConfig<\/em>.<\/p>\n<p>We use the <em>HashOperations<\/em> template that Spring Data Redis offers:<\/p>\n<pre class=\"brush:java\">@Repository\r\npublic class RedisRepositoryImpl implements RedisRepository {\r\n    private static final String KEY = \"Movie\";\r\n    \r\n    private RedisTemplate&lt;String, Object&gt; redisTemplate;\r\n    private HashOperations hashOperations;\r\n    \r\n    @Autowired\r\n    public RedisRepositoryImpl(RedisTemplate&lt;String, Object&gt; redisTemplate){\r\n        this.redisTemplate = redisTemplate;\r\n    }\r\n\r\n    @PostConstruct\r\n    private void init(){\r\n        hashOperations = redisTemplate.opsForHash();\r\n    }\r\n    \r\n    public void add(final Movie movie) {\r\n        hashOperations.put(KEY, movie.getId(), movie.getName());\r\n    }\r\n\r\n    public void delete(final String id) {\r\n        hashOperations.delete(KEY, id);\r\n    }\r\n    \r\n    public Movie findMovie(final String id){\r\n        return (Movie) hashOperations.get(KEY, id);\r\n    }\r\n    \r\n    public Map&lt;Object, Object&gt; findAllMovies(){\r\n        return hashOperations.entries(KEY);\r\n    }\r\n\r\n  \r\n}<\/pre>\n<p>Let\u2019s take note of the\u00a0<em>init()\u00a0<\/em>method. In this method, we use a function named\u00a0<em>opsForHash(), <\/em>which\u00a0returns the operations performed on hash values bound to the given key. We then use the\u00a0<em>hashOps<\/em>, which was defined in init(), for all our CRUD operations.<\/p>\n<h2>7. Web interface<\/h2>\n<p>In this section, we will review adding Redis CRUD operations capabilities to a web interface.<\/p>\n<h3>7.1 Add A Movie<\/h3>\n<p>We want to be able to add a Movie in our web page. The Key is the is the Movie <em>id<\/em> and the Value is the actual object. However, we will later address this so only the Movie name is shown as the value.<\/p>\n<p>So, let\u2019s add a form to a HTML document and assign appropriate names and ids :<\/p>\n<pre class=\"brush:xml\">&lt;form id=\"addForm\"&gt;\r\n&lt;div class=\"form-group\"&gt;\r\n                    &lt;label for=\"keyInput\"&gt;Movie ID (key)&lt;\/label&gt;\r\n                    &lt;input name=\"keyInput\" id=\"keyInput\" class=\"form-control\"\/&gt;\r\n                &lt;\/div&gt;\r\n&lt;div class=\"form-group\"&gt;\r\n                    &lt;label for=\"valueInput\"&gt;Movie Name (field of Movie object value)&lt;\/label&gt;\r\n                    &lt;input name=\"valueInput\" id=\"valueInput\" class=\"form-control\"\/&gt;\r\n                &lt;\/div&gt;\r\n                &lt;button class=\"btn btn-default\" id=\"addButton\"&gt;Add&lt;\/button&gt;\r\n            &lt;\/form&gt;<\/pre>\n<p>Now we use JavaScript to persist the values on form submission:<\/p>\n<pre class=\"brush:java\">$(document).ready(function() {\r\n    var keyInput = $('#keyInput'),\r\n        valueInput = $('#valueInput');\r\n\r\n    refreshTable();\r\n    $('#addForm').on('submit', function(event) {\r\n        var data = {\r\n            key: keyInput.val(),\r\n            value: valueInput.val()\r\n        };\r\n\r\n        $.post('\/add', data, function() {\r\n            refreshTable();\r\n            keyInput.val('');\r\n            valueInput.val('');\r\n            keyInput.focus();\r\n        });\r\n        event.preventDefault();\r\n    });\r\n\r\n    keyInput.focus();\r\n});<\/pre>\n<p>We assign the <em>@RequestMapping<\/em> value for the POST request, request the key and value, create a <em>Movie<\/em> object, and save it to the repository:<\/p>\n<pre class=\"brush:java\">@RequestMapping(value = \"\/add\", method = RequestMethod.POST)\r\n    public ResponseEntity&lt;String&gt; add(\r\n        @RequestParam String key,\r\n        @RequestParam String value) {\r\n        \r\n        Movie movie = new Movie(key, value);\r\n        \r\n        redisRepository.add(movie);\r\n        return new ResponseEntity&lt;&gt;(HttpStatus.OK);\r\n    }<\/pre>\n<h3>7.2 Viewing the content<\/h3>\n<p>Once a <em>Movie\u00a0<\/em>object is added, we refresh the table to display an updated table. In our JavaScript code block for section 7.1, we called a JavaScript function called\u00a0<em>refreshTable()<\/em>. This function performs a GET request to retrieve the current data in the repository:<\/p>\n<pre class=\"brush:java\">function refreshTable() {\r\n    $.get('\/values', function(data) {\r\n        var attr,\r\n            mainTable = $('#mainTable tbody');\r\n        mainTable.empty();\r\n        for (attr in data) {\r\n            if (data.hasOwnProperty(attr)) {\r\n                mainTable.append(row(attr, data[attr]));\r\n            }\r\n        }\r\n    });\r\n}<\/pre>\n<p>The GET request is processed by a method named<em> findAll()<\/em> that retrieves all the <em>Movie<\/em> objects stored in the repository and then converts the datatype from <em>Map&lt;Object, Object&gt;<\/em> to <em>Map&lt;String, String&gt;<\/em>:<\/p>\n<pre class=\"brush:java\">@RequestMapping(\"\/values\")\r\n    public @ResponseBody Map&lt;String, String&gt; findAll() {\r\n        Map&lt;Object, Object&gt; aa = redisRepository.findAllMovies();\r\n        Map&lt;String, String&gt; map = new HashMap&lt;String, String&gt;();\r\n        for(Map.Entry&lt;Object, Object&gt; entry : aa.entrySet()){\r\n            String key = (String) entry.getKey();\r\n            map.put(key, aa.get(key).toString());\r\n        }\r\n        return map;\r\n    }<\/pre>\n<h3>7.3 Delete a Movie<\/h3>\n<p>We write Javascript to do a POST request to<em>\u00a0<\/em><em>\/delete<\/em>, refresh the table, and set keyboard focus to key input:<\/p>\n<pre class=\"brush:java\">function deleteKey(key) {\r\n    $.post('\/delete', {key: key}, function() {\r\n        refreshTable();\r\n        $('#keyInput').focus();\r\n    });\r\n}<\/pre>\n<p>We request the key and delete the object in the <em>redisRepository\u00a0<\/em>based on this key:<\/p>\n<pre class=\"brush:java\">@RequestMapping(value = \"\/delete\", method = RequestMethod.POST)\r\n    public ResponseEntity&lt;String&gt; delete(@RequestParam String key) {\r\n        redisRepository.delete(key);\r\n        return new ResponseEntity&lt;&gt;(HttpStatus.OK);\r\n    }<\/pre>\n<h2>8. Demo<\/h2>\n<p>Here we added two movies:<br \/>\n<a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2017\/11\/add-key-redis-springboot.png\"><img decoding=\"async\" class=\"aligncenter wp-image-70920\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2017\/11\/add-key-redis-springboot.png\" alt=\"\" width=\"860\" height=\"380\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2017\/11\/add-key-redis-springboot.png 1024w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2017\/11\/add-key-redis-springboot-300x132.png 300w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2017\/11\/add-key-redis-springboot-768x339.png 768w\" sizes=\"(max-width: 860px) 100vw, 860px\" \/><\/a><\/p>\n<p>Here we removed one movie:<br \/>\n<a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2017\/11\/delete-key-redis-springboot.png\"><img decoding=\"async\" class=\"aligncenter wp-image-70921\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2017\/11\/delete-key-redis-springboot.png\" alt=\"\" width=\"860\" height=\"400\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2017\/11\/delete-key-redis-springboot.png 1024w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2017\/11\/delete-key-redis-springboot-300x139.png 300w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2017\/11\/delete-key-redis-springboot-768x357.png 768w\" sizes=\"(max-width: 860px) 100vw, 860px\" \/><\/a><\/p>\n<h2>9. Conclusion<\/h2>\n<p>In this tutorial, we introduced Spring Data Redis and one way of connecting it to a web application to perform CRUD operations.<\/p>\n<p>The source code for the example application is on <a href=\"https:\/\/github.com\/michaelcgood\/spring-data-redis-example\" target=\"_blank\" rel=\"noopener\">Github<\/a>.<\/p>\n<div class=\"attribution\">\n<table>\n<tbody>\n<tr>\n<td>Published on Java Code Geeks with permission by Michael Good, partner at our <a href=\"http:\/\/www.javacodegeeks.com\/join-us\/jcg\/\" target=\"_blank\" rel=\"noopener\">JCG program<\/a>. See the original article here: <a href=\"http:\/\/michaelcgood.com\/intro-redis-with-spring-boot\/\" target=\"_blank\" rel=\"noopener\">Intro to Redis with Spring Boot<\/a><\/p>\n<p>Opinions expressed by Java Code Geeks contributors are their own.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>1. Overview In this article, we will review the basics of how to use Redis with Spring Boot through the Spring Data Redis library. We will build an application that demonstrates how to perform CRUD operations Redis through a web interface. The full source code for this project is available on Github. 2. What is &hellip;<\/p>\n","protected":false},"author":5558,"featured_media":223,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[117,30],"class_list":["post-70914","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-enterprise-java","tag-redis","tag-spring"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Intro to Redis with Spring Boot - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"1. Overview In this article, we will review the basics of how to use Redis with Spring Boot through the Spring Data Redis library. We will build an\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.javacodegeeks.com\/2017\/11\/intro-redis-spring-boot.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Intro to Redis with Spring Boot - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"1. Overview In this article, we will review the basics of how to use Redis with Spring Boot through the Spring Data Redis library. We will build an\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2017\/11\/intro-redis-spring-boot.html\" \/>\n<meta property=\"og:site_name\" content=\"Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2017-11-28T11:00:02+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/redis-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Michael Good\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Michael Good\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2017\\\/11\\\/intro-redis-spring-boot.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2017\\\/11\\\/intro-redis-spring-boot.html\"},\"author\":{\"name\":\"Michael Good\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/d13cc729556b91450ae21878a82139ed\"},\"headline\":\"Intro to Redis with Spring Boot\",\"datePublished\":\"2017-11-28T11:00:02+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2017\\\/11\\\/intro-redis-spring-boot.html\"},\"wordCount\":883,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2017\\\/11\\\/intro-redis-spring-boot.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/redis-logo.jpg\",\"keywords\":[\"Redis\",\"Spring\"],\"articleSection\":[\"Enterprise Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2017\\\/11\\\/intro-redis-spring-boot.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2017\\\/11\\\/intro-redis-spring-boot.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2017\\\/11\\\/intro-redis-spring-boot.html\",\"name\":\"Intro to Redis with Spring Boot - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2017\\\/11\\\/intro-redis-spring-boot.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2017\\\/11\\\/intro-redis-spring-boot.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/redis-logo.jpg\",\"datePublished\":\"2017-11-28T11:00:02+00:00\",\"description\":\"1. Overview In this article, we will review the basics of how to use Redis with Spring Boot through the Spring Data Redis library. We will build an\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2017\\\/11\\\/intro-redis-spring-boot.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2017\\\/11\\\/intro-redis-spring-boot.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2017\\\/11\\\/intro-redis-spring-boot.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/redis-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/redis-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2017\\\/11\\\/intro-redis-spring-boot.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Enterprise Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\\\/enterprise-java\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Intro to Redis with Spring Boot\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Developers Resource Center\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.javacodegeeks.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/javacodegeeks\",\"https:\\\/\\\/x.com\\\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/d13cc729556b91450ae21878a82139ed\",\"name\":\"Michael Good\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/dc6ef7dbff80afe08a3cdc3b0677aaa26021085e041ce1873dc2141bc581b623?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/dc6ef7dbff80afe08a3cdc3b0677aaa26021085e041ce1873dc2141bc581b623?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/dc6ef7dbff80afe08a3cdc3b0677aaa26021085e041ce1873dc2141bc581b623?s=96&d=mm&r=g\",\"caption\":\"Michael Good\"},\"description\":\"Michael is a software engineer located in the Washington DC area that is interested in Java, cyber security, and open source technologies. Follow his personal blog to read more from Michael.\",\"sameAs\":[\"http:\\\/\\\/www.michaelcgood.com\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/michael-good\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Intro to Redis with Spring Boot - Java Code Geeks","description":"1. Overview In this article, we will review the basics of how to use Redis with Spring Boot through the Spring Data Redis library. We will build an","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.javacodegeeks.com\/2017\/11\/intro-redis-spring-boot.html","og_locale":"en_US","og_type":"article","og_title":"Intro to Redis with Spring Boot - Java Code Geeks","og_description":"1. Overview In this article, we will review the basics of how to use Redis with Spring Boot through the Spring Data Redis library. We will build an","og_url":"https:\/\/www.javacodegeeks.com\/2017\/11\/intro-redis-spring-boot.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2017-11-28T11:00:02+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/redis-logo.jpg","type":"image\/jpeg"}],"author":"Michael Good","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Michael Good","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2017\/11\/intro-redis-spring-boot.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2017\/11\/intro-redis-spring-boot.html"},"author":{"name":"Michael Good","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/d13cc729556b91450ae21878a82139ed"},"headline":"Intro to Redis with Spring Boot","datePublished":"2017-11-28T11:00:02+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2017\/11\/intro-redis-spring-boot.html"},"wordCount":883,"commentCount":0,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2017\/11\/intro-redis-spring-boot.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/redis-logo.jpg","keywords":["Redis","Spring"],"articleSection":["Enterprise Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/2017\/11\/intro-redis-spring-boot.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2017\/11\/intro-redis-spring-boot.html","url":"https:\/\/www.javacodegeeks.com\/2017\/11\/intro-redis-spring-boot.html","name":"Intro to Redis with Spring Boot - Java Code Geeks","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2017\/11\/intro-redis-spring-boot.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2017\/11\/intro-redis-spring-boot.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/redis-logo.jpg","datePublished":"2017-11-28T11:00:02+00:00","description":"1. Overview In this article, we will review the basics of how to use Redis with Spring Boot through the Spring Data Redis library. We will build an","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2017\/11\/intro-redis-spring-boot.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2017\/11\/intro-redis-spring-boot.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2017\/11\/intro-redis-spring-boot.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/redis-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/redis-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/2017\/11\/intro-redis-spring-boot.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java","item":"https:\/\/www.javacodegeeks.com\/category\/java"},{"@type":"ListItem","position":3,"name":"Enterprise Java","item":"https:\/\/www.javacodegeeks.com\/category\/java\/enterprise-java"},{"@type":"ListItem","position":4,"name":"Intro to Redis with Spring Boot"}]},{"@type":"WebSite","@id":"https:\/\/www.javacodegeeks.com\/#website","url":"https:\/\/www.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Developers Resource Center","publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/d13cc729556b91450ae21878a82139ed","name":"Michael Good","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/dc6ef7dbff80afe08a3cdc3b0677aaa26021085e041ce1873dc2141bc581b623?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/dc6ef7dbff80afe08a3cdc3b0677aaa26021085e041ce1873dc2141bc581b623?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/dc6ef7dbff80afe08a3cdc3b0677aaa26021085e041ce1873dc2141bc581b623?s=96&d=mm&r=g","caption":"Michael Good"},"description":"Michael is a software engineer located in the Washington DC area that is interested in Java, cyber security, and open source technologies. Follow his personal blog to read more from Michael.","sameAs":["http:\/\/www.michaelcgood.com"],"url":"https:\/\/www.javacodegeeks.com\/author\/michael-good"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/70914","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/users\/5558"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=70914"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/70914\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/223"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=70914"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=70914"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=70914"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}