Skip to content

Commit 67e281e

Browse files
author
EC2 Default User
committed
Adding metadata files and sample data
1 parent 72cb1ce commit 67e281e

File tree

11 files changed

+106
-1
lines changed

11 files changed

+106
-1
lines changed
-3.67 KB
Binary file not shown.
-3.75 KB
Binary file not shown.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
dist/
2+
build/
3+
write-through-cache.egg-info
4+
write-through-cache/__pycache__/
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include write_through_caching_sample/resources/sf-class2-root.crt
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
## Using Amazon Elasticache with Redis OSS compatibility as a cache for Amazon Keyspaces
2+
3+
This sample project shows the use of the Amazon Elasticache Redis as a cache for book awards data stored in Amazon Keyspaces. The sample uses DataStax Python Driver for Apache Cassandra to connect to Amazon Keyspaces, and Redis Client to connect to Amazon Elasticache Redis. SigV4 has been used for authentication using short-term credentials.
4+
5+
### Prerequisites
6+
You should have Python and pip installed. This sample works with Python 3.x.
7+
8+
You should also setup Amazon Keyspaces with an IAM user. See [Accessing Amazon Keyspaces](https://docs.aws.amazon.com/keyspaces/latest/devguide/accessing.html) for more.
9+
10+
You need the Starfield digital certificate 'sf-class2-root.crt' downloaded locally or in your home directory - provide the certificate path on line 13 of write_through_caching_sample/ks_redis.py. The certificate can be found at write_through_caching_sample/resources.
11+
12+
You should have the connection string for your Amazon Elasticache Redis cluster which you will provide on line of write_through_caching_sample/ks_redis.py.
13+
14+
You should have the keyspace name and table name for your Amazon Keyspaces resource which you will provide on line 36 and line 37 of write_through_caching_sample/ks_redis.py respectively.
15+
16+
Sample data can be found at write_through_caching_sample/resources/ and can be loaded using [CQLSH] (https://docs.aws.amazon.com/keyspaces/latest/devguide/bulk-upload.html) or [DSBulk] (https://docs.aws.amazon.com/keyspaces/latest/devguide/dsbulk-upload.html).
17+
18+
19+
### Running the sample
20+
21+
This sample uses Boto3 which will find credentials based on environment variables, config or credentials file on your client, see [Boto3 Credentials Guide](https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html) for how to set this up.
22+
23+
You can quickly get this to run by explicitly setting the following environment variables...
24+
25+
- AWS_REGION (for example 'us-east-1)
26+
- AWS_ACCESS_KEY_ID (ex: 'AKIAIOSFODNN7EXAMPLE')
27+
- AWS_SECRET_ACCESS_KEY (ex: 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY')
28+
29+
### Install the dependencies
30+
31+
From the project directory...
32+
```
33+
$ python3 -m pip install .
34+
```
35+
36+
### Testing
37+
From this project directory...
38+
```
39+
$ python3 write_through_caching_sample/test_functions.py
40+
```
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
cassandra-driver
2+
cassandra-sigv4
3+
redis-py-cluster
4+
boto3
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from setuptools import setup, find_packages
2+
3+
setup(
4+
name='write_through_caching_sample',
5+
version='1.0',
6+
include_package_data=True,
7+
packages=['write_through_cachine_sample'],
8+
install_requires=[
9+
'cassandra-driver',
10+
'cassandra-sigv4',
11+
'redis-py-cluster',
12+
'boto3'
13+
],
14+
15+
)

ks_redis.py renamed to elasticache/write-through-cache/write_through_caching_sample/ks_redis.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
#Amazon Elasticache connection
2525
logging.basicConfig(level=logging.ERROR)
26-
redis = RedisCluster(startup_nodes=[{"host": "keyspaces-cache.ebnqkc.clustercfg.use1.cache.amazonaws.com",
26+
redis = RedisCluster(startup_nodes=[{"host": "YOUR_CLUSTER.clustercfg.use1.cache.amazonaws.com",
2727
"port": "6379"}],
2828
decode_responses=True,
2929
skip_full_coverage_check=True)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
"award","year","book_title","author","rank","publisher","category"
2+
"Must Read",2021,"The mystery of the 7th dimension","Polly Gon",1,"PublishGo","Sci-Fi"
3+
"Must Read",2021,"Time travellers guide","Kai K",2,"Publish123","Sci-Fi"
4+
"Must Read",2021,"Key to the teleporter","Mick Key",3,"Penguins","Sci-Fi"
5+
"Must Read",2021,"Victors Mars","Anonymous",4,"PinkPublish","Sci-Fi"
6+
"Must Read1",2021,"Tomorrow is here","John Doe",2,"Ostrich books1","Sci-Fi"
7+
"Must Read1",2021,"Tomorrow is here","John Doe",3,"Ostrich books1","Sci-Fi"
8+
"International Best Seller",2023,"Adventures of Ji","Ji Jill",1,"PublishGo","Young Adult"
9+
"International Best Seller",2023,"The Chronicles of Myrtlini","Jane Doe",2,"Penguins","Young Adult"
10+
"International Best Seller",2023,"Dreams","Gigi",3,"WellPublishers","Young Adult"
11+
"International Best Seller",2023,"Vision of Utopia","Anonymous",4,"ABCPublish","Young Adult"
12+
"International Best Seller",2023,"The sailor said..","Pyter P",5,"PublishGo","Young Adult"
13+
"Must read",2056,"Postcard from Andromeda","James Doe",1,"Publish123","sci-fi"
14+
"Must read",2056,"Postcard from Almeda","James Doug",2,"Publish123","sci-fi"
15+
"Must read",2056,"Postcard from Mars","James Doug",5,"Publish123","sci-fi"
16+
"Golden Read",2056,"Postcard from Andromeda","James Doe",1,"Publish123","sci-fi"
17+
"Golden Read",2056,"Tomorrow is here","John Doe",2,"Ostrich books","sci-fi"
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
-----BEGIN CERTIFICATE-----
2+
MIIEDzCCAvegAwIBAgIBADANBgkqhkiG9w0BAQUFADBoMQswCQYDVQQGEwJVUzEl
3+
MCMGA1UEChMcU3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEyMDAGA1UECxMp
4+
U3RhcmZpZWxkIENsYXNzIDIgQ2VydGlmaWNhdGlvbiBBdXRob3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L7ShZ3U0WixeDyLJl
21+
xy16paq8U4Zt3VekyvggQQto8PT7dL5WXXp59fkdheMtlb71cZBDzI0fmgAKhynp
22+
VSJYACPq4xJDKVtHCN2MQWplBqjlIapBtJUhlbl90TSrE9atvNziPTnNvT51cKEY
23+
WQPJIrSPnNVeKtelttQKbfi3QBFGmh95DmK/D5fs4C8fF5Q=
24+
-----END CERTIFICATE-----

0 commit comments

Comments
 (0)