UNPKG

@amazon-dax-sdk/client-dax

Version:

Amazon DAX Client for JavaScript

87 lines (64 loc) 2.65 kB
# Amazon DAX Client for JavaScript DAX is a DynamoDB-compatible caching service that enables you to benefit from fast in-memory performance for demanding applications. ## Overview This client library provides access from NodeJS to DAX. ## Installing The Amazon DAX client only runs from NodeJS, and can be installed using npm: ```sh npm install @amazon-dax-sdk/client-dax ``` ## Usage and Getting Started You can follow the Getting Started tutorial at: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DAX.client.sample-app.html To quickly use DAX, replace `DynamoDB` full client with `Dax`: ```javascript import { Dax } from '@amazon-dax-sdk/client-dax'; import { DynamoDB } from '@aws-sdk/client-dynamodb'; // Replace this ... var client = new DynamoDB({region: region}); // with this ... const endpoint = "your-cluster-discovery-endpoint"; client = new Dax({endpoints: [endpoint], region: region}); ``` The DAX Cluster Discovery Endpoint can be found in the AWS console or by using `aws dax describe-clusters` from the command line. Creating a connection to your DAX cluster requires using the Cluster Discovery Endpoint URL returned in the DescribeClusters response as the endpoint. For example: ```javascript // Format: const endpoint = <ClusterDiscoveryEndpoint.URL>; const endpoint = 'dax://my-cluster.abc123.dax-clusters.us-east-1.amazonaws.com'; // Encrypted Cluster Endpoint const endpoint = 'daxs://my-cluster.abc123.dax-clusters.us-east-1.amazonaws.com'; ``` ### Calling Operations ```javascript import { Dax } from '@amazon-dax-sdk/client-dax'; import { DynamoDB } from '@aws-sdk/client-dynamodb'; // Override Client ... var client = new DynamoDB({region: region}); // with this ... const endpoint = "your-cluster-discovery-endpoint"; client = new Dax({endpoints: endpoint, region: region}); var params = { TableName: 'TryDaxTable', pk: {N: '1'}, sk: {S: '1'} } // Similarly for other data plane calls client.getItem(params).then((res)=>{ console.log(res); }).catch(err=>{ throw err; }); ``` ## Getting Help Please use these community resources for getting help. * Ask a question on [StackOverflow](https://stackoverflow.com/) and tag it with `amazon-dynamodb-dax` * Ask a question on [the AWS DynamoDB forum](https://forums.aws.amazon.com/forum.jspa?forumID=131&start=0) * Open a support ticket with [AWS Support](https://console.aws.amazon.com/support/home#/) ## Changes #### 3.0.3 * Optimized clean-up of connections during timeouts #### 3.0.2 * Added support to limit concurrent connections that a client instance can create per node in DAX cluster #### 3.0.1 * Initial release