- cachy
Cachy is a lightweight in-memory cache api. Godoc
- No thirdparty libraries.
- Docker image.
To be avoided from circular reference error, we have to obtain these rules.
-
Api Layer
includes controllers, request handlers, and routing files should be here. You can just reference Business Layer, Data Layer and Framework Layer. -
Business Layer
includes all business logics, structures, service files. You can just reference Data layer and Framework layer. -
Data Layer
Models, DTOs, views, constants should be here. Youcannot reference any project
. -
Framework Layer
Global extension structures, methods, some helper methods without business. You can just reference Data layer.
{
"backup_file_path": "TIMESTAMP-data.json",
"backup_interval": "30" //by sec
}
Param Name | Variable Type | Requirement | Description | Value |
---|---|---|---|---|
backup_file_path | :string |
no | Path for backing up | Described below |
backup_interval | :string |
no | Interval for backing up | 10 , 30 , 60 ... by any seconds |
darwin -> "/tmp/TIMESTAMP-data.json"
linux -> "/tmp/TIMESTAMP-data.json"
windows -> "TIMESTAMP-data.json"
Step 1: git clone this repository hayrullahcansu/cachy@github
git clone https://github.com/hayrullahcansu/cachy.git
Go to project folder
cd cachy
go mod download
go test -v ./...
go run ./api/main.go
└─(00:51:23 on master ✹)──> go run ./api/main.go ──(Fri,Oct15)─┘
INFO: 2021/10/15 00:51:34 logging.go:65: Starting service for cachy
2021/10/15 00:51:34 Defaulting to port 8080
2021/10/15 00:51:34 Listening on port 8080
Hosted in heroku.
https://cachy-api.herokuapp.com/api/v1
All endpoints here
- Cache Resource
/api/v1/cache
-
GET
/
List of all cache entries -
GET
/{cache_key}
returns cache entry- Response body:
{ "key": "cachy_test_key", "value": "cachy_test_value", "expire_at": "13-10-2021 17:57:30" }
-
POST
/{cache_key}
sets new cache entry- Request body:
{ "time_span": 10, "data":"cachy_test_value" }
- Response body:
{ "key": "cachy_test_key", "value": "cachy_test_value", "expire_at": "13-10-2021 17:57:30" }
-
PUT
/{cache_key}
updates existing cache entry- Request body:
{ "time_span": 20, "data":"cachy_test_value" }
- Response body:
{ "key": "cachy_test_key", "value": "cachy_test_value", "expire_at": "13-10-2021 18:00:18" }
-
DELETE
/{cache_key}
removes cache entry -
DELETE
/flush
removes all cache entries
-
- Create docker image
docker build -t cachy-api --squash .
- Create/Run a docker container
docker run -d --rm -p 8080:8080 --name cachy-api-1 cachy-api
- Design Patters
- Readme File
- Go Doc
- ApiDoc
- Tests
- Logging for Http Requests that are incoming in
server.log
file - Docker Support
- Deploy (Heroku, aws)