Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add scalar storage support for DynamoDB #531

Merged
merged 2 commits into from
Sep 5, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
feat: Add scalar storage support for DynamoDB
This change allows GPTCache to use DynamoDB as the underlying scalar
storage for the cache.

The underlying implementation uses 2 tables:

- `gptcache_questions` - which holds all questions and session
  information.
- `gptcache_reports` - which holds the reporting information.

Normally, we would do a single table design and rollup
`gptcache_reports` into the same table as `gptcache_questions`. However,
this was not done for one key reason: billing.

In the event a lot of analytics data is being created, then table scans
for operations like `count()` and `get_ids()` would also involve reading
these reporting rows before filtering them out, resulting in higher
read costs for end users of GPTCache.

Signed-off-by: Gautham Chandra <gautham.chandra@live.com>
  • Loading branch information
gauthamchandra committed Sep 2, 2023
commit 35d87040428c8a3e6e743a3dc50eacda55578ecb
5 changes: 5 additions & 0 deletions .github/workflows/unit_test_main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ jobs:
image: redis/redis-stack-server
ports:
- 6379:6379
dynamodb:
image: amazon/dynamodb-local:2.0.0
# rebinding to a different port since 8000 is a commonly used port
ports:
- 9999:8000
mongo:
image: mongo
ports:
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ This module is created to extract embeddings from requests for similarity search
- [x] Support [MariaDB](https://mariadb.org/).
- [x] Support [SQL Server](https://www.microsoft.com/en-us/sql-server/).
- [x] Support [Oracle](https://www.oracle.com/).
- [x] Support [DynamoDB](https://aws.amazon.com/dynamodb/).
- [ ] Support [MongoDB](https://www.mongodb.com/).
- [ ] Support [Redis](https://redis.io/).
- [ ] Support [Minio](https://min.io/).
Expand Down
1 change: 1 addition & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ Support general database
- MariaDB.
- SQL Server.
- Oracle.
- DynamoDB

> [Example code](https://github.com/zilliztech/GPTCache/blob/main/examples/data_manager/scalar_store.py)

Expand Down
1 change: 1 addition & 0 deletions examples/data_manager/scalar_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def run():
CacheBase('mariadb', sql_url='mariadb+pymysql://root:123456@127.0.0.1:3307/mysql'),
CacheBase('sqlserver', sql_url='ssql+pyodbc://sa:Strongpsw_123@127.0.0.1:1434/msdb?driver=ODBC+Driver+17+for+SQL+Server'),
CacheBase('oracle', sql_url='oracle+cx_oracle://oracle:123456@127.0.0.1:1521/?service_name=helowin&encoding=UTF-8&nencoding=UTF-8'),
CacheBase('dynamo'),
]

for scalar_store in scalar_stores:
Expand Down
Loading