Code Monkey home page Code Monkey logo

replicated-cache's Introduction

EhCache Replication Example

Build

Explore the Project's Repository

Clone the Repository

git clone https://github.com/skrymets/replicated-cache.git 

Build the Project

cd replicated-cache
mvn clean install -DskipTests=true

Build Docker Image

docker image build . -t cache-demo:1.0.0

Play

Run Application's instances in two nodes by Docker Composer

docker-compose.exe up

You will see an output like this

Creating replicated-cache_node1_1 ... done
Creating replicated-cache_node2_1 ... done
Attaching to replicated-cache_node1_1, replicated-cache_node2_1

  • Node 1 REST Service will start on port 8080
  • Node 2 REST Service will start on port 8081

Use curl to read/write values from/in cache via the REST interface.

Write a value to the Node 1

curl -X POST -H "key:keyValue" -H "value:valueData" http://localhost:8080/set

node1_1 | 2020-03-24 22:21:18.277 INFO 1 --- [nio-8080-exec-2] s.replicated.cache.shell.RestShell : Setup value for key keyValue == valueData
node1_1 | 2020-03-24 22:21:18.280 INFO 1 --- [nio-8080-exec-2] s.replicated.cache.CachingRepository : Update value in the cache: keyValue: valueData
node2_1 | 2020-03-24 22:21:19.116 DEBUG 1 --- [n(5)-172.17.0.2] n.sf.ehcache.distribution.RMICachePeer : RMICachePeer for cache inMemoryFeatures: remote remove received for key: feature-keyValue

Now read a value by the provided key from the Node 1

curl -X GET http://localhost:8080/read?key=keyValue

You'll get:

valueData

Now read a value by the provided key from the Node 2

curl -X GET http://localhost:8081/read?key=keyValue

And ... magically ... you'll get the same value:

valueData

Explore the logs output in console for more details.

Shutdown the nodes

docker-compose.exe down

Setup Info

EhCache RMI Setup

replicated-cache's People

Contributors

skrymets 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.