GithubHelp home page GithubHelp logo

aws-samples / amazon-elasticache-redis-and-memcached-java-client-examples Goto Github PK

View Code? Open in Web Editor NEW
9.0 2.0 11.0 1.56 MB

Examples for using Java clients to interact with Amazon ElastiCache for Redis using the open-source Redis client Jedis and Amazon ElastiCache for Memcached using the ElastiCache Cluster Client.

License: MIT No Attribution

Java 100.00%
java11 java amazon-elasticache redis-client jedis

amazon-elasticache-redis-and-memcached-java-client-examples's Introduction

Amazon ElastiCache for Redis and Memcached - Java client examples

This repository contains examples for using Java clients to interact with Amazon ElastiCache for Redis and Memcached. These examples demonstrate the following,

  • How to connect/disconnect to Amazon ElastiCache for Redis using the open-source Redis client Jedis.
  • How to connect/disconnect to Amazon ElastiCache for Memcached using the ElastiCache Cluster Client.
  • Add/update entries in the cache.
  • Lookup cache values by key.
  • Delete cache entries by key.

Overview

Amazon ElastiCache makes it easy to set up, manage and scale distributed in-memory cache environments in the AWS Cloud. It provides a high performance, resizable and cost-effective in-memory cache, while removing complexity associated with deploying and managing a distributed cache environment. ElastiCache works with both the open source Redis and the open source Memcached engines.

Repository structure

This repository contains the following directories,

  • src - the Java source files for your reference.

  • dist - the distributable with jar files, configuration files and Linux/Windows scripts. The instructions to run these are specified below.

Prerequisites to run the examples

Prior to running these examples, make sure you have all the following components configured in the same AWS region and in the same AWS account.

Amazon ElastiCache clusters:

Note: These should be created with location as 'Amazon Cloud' and in private subnet groups in the same VPC.

  1. An Amazon ElastiCache Redis cluster with cluster-mode disabled. Refer here.
  2. An Amazon ElastiCache Redis cluster with cluster-mode enabled. Refer here.
  3. An Amazon ElastiCache Memcached cluster. Refer here.

Security groups:

  1. On the Redis clusters, the security group should provide inbound TCP access on port 6379 from the EC2 instance that is to be configured in the following steps.

  2. On the Memcached cluster, the security group should provide inbound TCP access on port 11211 from the EC2 instance that is to be configured in the following steps.

  3. On the EC2 instance to be created in the following steps, the security group should provide outbound TCP access on port 6379 to the Redis clusters and outbound TCP access on port 11211 to the Memcached cluster.

IAM role:

Note: An IAM role is global and not constrained to a region.

  1. An IAM role with full access to operate on these clusters. For more info on this, refer here.

Amazon EC2 instance:

  1. An Amazon EC2 instance in Linux/Windows with this IAM role attached and in the same VPC as the ElastiCache clusters created in the previous steps. The subnet should be private, preferably one that is part of the private subnet group configured for the ElastiCache clusters.
  2. Java 11 (Amazon Corretto 11 or Oracle JDK 11) should be installed in this instance.

How to run the examples

  1. Copy the dist folder to your preferred folder in the EC2 instance.
  2. Configure the properties:

a. Specify the ElastiCache cluster URL depending on the type of the cluster in the appropriate .properties file.

b. If you prefer, you can leave the other properties as-is; else update them as required.

  1. Configure the scripts in the bin directory:

a. If the EC2 instance is a Linux instance, then open the .sh scripts in the bin-linux.

b. If the EC2 instance is a Windows instance, then open the .bat scripts in the bin-windows.

c. Set the following variables:

TOOL_HOME to the full path of the dist directory in the file system.

JAVA_CMD to the full path to the Java 11 'java' executable in the file system.

d. Set execute permissions on these scripts.

  1. Run the scripts and observe the output.

Security

See CONTRIBUTING for more information.

License

This library is licensed under the MIT-0 License. See the LICENSE file.

amazon-elasticache-redis-and-memcached-java-client-examples's People

Contributors

amazon-auto avatar gv-tech avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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