https://github.com/smarttoolfactory/transactional-key-value-store
Transactional Key Value Store written with Jetpack Compose
https://github.com/smarttoolfactory/transactional-key-value-store
android jetpack-compose room-database transactional-database transactional-memory
Last synced: about 2 months ago
JSON representation
Transactional Key Value Store written with Jetpack Compose
- Host: GitHub
- URL: https://github.com/smarttoolfactory/transactional-key-value-store
- Owner: SmartToolFactory
- Created: 2023-02-12T17:55:43.000Z (over 2 years ago)
- Default Branch: develop
- Last Pushed: 2023-02-19T20:09:03.000Z (over 2 years ago)
- Last Synced: 2025-04-04T10:25:57.164Z (2 months ago)
- Topics: android, jetpack-compose, room-database, transactional-database, transactional-memory
- Language: Kotlin
- Homepage:
- Size: 155 KB
- Stars: 5
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Compose Transactional Key-Value Store
A transactional key-value store Sample written with Jetpack Compose with Room database
to store commits.https://user-images.githubusercontent.com/35650605/218341574-3b914472-a391-4194-a271-d0e54c1b9845.mp4
## Tech Stack
* Jetpack Compose
* Dagger Hilt
* Room Database for persisting COMMIT transactions
* MVVM and clean architecture
* Unit and Database Tests(More tests to be written)## Assignment
The assignment is to build an interactive command line interface to a transactional key value store. A user should be able to compile and run this program and get an interactive shell with a prompt where they can type commands. The user can enter commands to set/get/delete key/value pairs and count values. All values can be treated as strings, no need to differentiate by type. The key/value data only needs to exist in memory for the session, it does not need to be written to disk.
The interface should also allow the user to perform operations in transactions, which allows the user to commit or roll back their changes to the key value store. That includes the ability to nest transactions and roll back and commit within nested transactions. The solution shouldn’t depend on any third party libraries. The interface should support the following commands:
```
SET // store the value for key
GET // return the current value for key
DELETE // remove the entry for key
COUNT // return the number of keys that have the given value
BEGIN // start a new transaction
COMMIT // complete the current transaction
ROLLBACK // revert to state prior to BEGIN call
```### Set and get a value:
```
> SET foo 123
> GET foo
123
```### Delete a value
```
> DELETE foo
> GET foo
key not set
```### Count the number of occurrences of a value
```
> SET foo 123
> SET bar 456
> SET baz 123
> COUNT 123
2
> COUNT 456
1
```### Commit a transaction
```
> BEGIN
> SET foo 456
> COMMIT
> ROLLBACK
no transaction
> GET foo
456
```### Rollback a transaction
```
> SET foo 123
> SET bar abc
> BEGIN
> SET foo 456
> GET foo
456
> SET bar def
> GET bar
def
> ROLLBACK
> GET foo
123
> GET bar
abc
> COMMIT
no transaction
```### Nested transactions
```
> SET foo 123
> SET bar 456
> BEGIN
> SET foo 456
> BEGIN
> COUNT 456
2
> GET foo
456
> SET foo 789
> GET foo
789
> ROLLBACK
> GET foo
456
> DELETE foo
> GET foo
key not set
> ROLLBACK
> GET foo
123
```