GithubHelp home page GithubHelp logo

spring-boot-infinispan's Introduction

Spring Boot Infinispan Example

This project is a demonstration of using Infinispan to drive Spring Boot caching. The application is based off of the existing "spring-boot-sample-data-rest" application, with changes made to configure caching, Infinispan, and clustering.

Getting Started

You will need to have Maven and Java installed. Maven will need to have the Maven Central repository, which is where the project dependencies are available.

After downloading this project, run the following command:

mvn clean install

This will build the project. You should observe a successful build, with all tests passing.

Once the build is complete, run the following command to start the application:

java -Djava.net.preferIPv4Stack=true -jar target/spring-boot-sample-data-rest-1.4.3.RELEASE.jar --server.port=8080 

Change the value of the last argument to set the port of the application. Running this script multiple times in different terminal sessions, changing the port for each, will cluster the applications (assuming multicast is enabled for the machine they're running on).

Testing

Once the application is running, you can access data through the following endpoints:

http://localhost:8080/api/cities/search/findByNameAndCountryAllIgnoringCase?name=Sydney&country=Australia
http://localhost:8080/api/cities/search/findByNameContainingAndCountryContainingAllIgnoringCase?name=&country=UK

Hibernate is configured to log when a query is executed. If the cache is functioning properly, if you hit the same endpoint twice, the query will only be executed once against the database. However, cache data will be removed after a timeout or if a maximum number of entries are stored in the cache - see infinispan.xml for details.

Try hitting the endpoint for one application process, then on another. The data should stay in the cache, so the second application process shouldn't have to hit the database for the data.

Authorship and Acknowledgments

Original application by spring-boot team:

https://github.com/spring-projects/spring-boot/blob/master/spring-boot-samples/spring-boot-sample-data-rest/

Cache code and Infinispan configuration added by Trevor Xiao.

spring-boot-infinispan's People

Contributors

tkterris avatar

Watchers

 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.