Cachy is a simple and lightweight in-memory cache api.

cachy

bashtop

Table of Contents


Description

Cachy is a lightweight in-memory cache api. Godoc

Features

  • No thirdparty libraries.
  • Docker image.

Structure

structure

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. You cannot reference any project.

  • Framework Layer Global extension structures, methods, some helper methods without business. You can just reference Data layer.

Configurability

settings.json

{
  "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

default values for backup_file_path

darwin   ->  "/tmp/TIMESTAMP-data.json"
linux    ->  "/tmp/TIMESTAMP-data.json"
windows  ->  "TIMESTAMP-data.json"

Run on Local

Step 1: git clone this repository hayrullahcansu/cachy@github

git clone https://github.com/hayrullahcansu/cachy.git

Go to project folder

cd cachy

Step 2: download dependencies

go mod download

Step 3: run test

go test -v ./... 

Step 4: run cachy (It will start to listen on 8080 default port) [env key: PORT]

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

Test API

Hosted in heroku.

https://cachy-api.herokuapp.com/api/v1

Rest API Document

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

Docker

  • 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

TODO

  • Design Patters
  • Readme File
  • Go Doc
  • ApiDoc
  • Tests
  • Logging for Http Requests that are incoming in server.log file
  • Docker Support
  • Deploy (Heroku, aws)
Owner
Hayrullah cansu
Software Engineer
Hayrullah cansu
Similar Resources

Gocodecache - An in-memory cache library for code value master in Golang

gocodecache An in-memory cache library for code master in Golang. Installation g

Jun 23, 2022

Ristretto - A high performance memory-bound Go cache

Ristretto Ristretto is a fast, concurrent cache library built with a focus on pe

Dec 5, 2022

A zero-dependency cache library for storing data in memory with generics.

Memory Cache A zero-dependency cache library for storing data in memory with generics. Requirements Golang 1.18+ Installation go get -u github.com/rod

May 26, 2022

A Lightweight "Remote Cache Access" (Rekas) Framework

Rekas 项目介绍 Rekas:一个轻量级分布式缓存系统 框架 ,解决缓存系统中出现的缓存击穿[锁机制]、缓存穿透[布隆过滤器]、缓存雪崩[分布式]问题,实现

Jun 21, 2022

🦉owlcache is a lightweight, high-performance, non-centralized, distributed Key/Value memory-cached data sharing application written by Go

 🦉owlcache is a lightweight, high-performance, non-centralized, distributed Key/Value memory-cached data sharing application written by Go

🦉owlcache is a lightweight, high-performance, non-centralized, distributed Key/Value memory-cached data sharing application written by Go . keyword : golang cache、go cache、golang nosql

Nov 5, 2022

API Cache is a simple caching server, using grpc to accept messages.

API Cache is a simple caching server, using grpc to accept messages. It allows to store key-value pairs, where key is string and value is []byte.

Nov 16, 2021

Lru - A simple LRU cache using go generics

LRU Cache A simple LRU cache using go generics. Examples Basic usage. func main(

Nov 9, 2022

A simple generic in-memory caching layer

sc sc is a simple in-memory caching layer for golang. Usage Wrap your function with sc - it will automatically cache the values for specified amount o

Jul 2, 2022

🧩 Redify is the optimized key-value proxy for quick access and cache of any other database throught Redis and/or HTTP protocol.

Redify (Any database as redis) License Apache 2.0 Redify is the optimized key-value proxy for quick access and cache of any other database throught Re

Sep 25, 2022
Related tags
A REST-API service that works as an in memory key-value store with go-minimal-cache library.

A REST-API service that works as an in memory key-value store with go-minimal-cache library.

Aug 25, 2022
In Memory cache in GO Lang Api

In memory key-value store olarak çalışan bir REST-API servisi Standart Kütüphaneler kullanılmıştır Özellikler key ’i set etmek için bir endpoint key ’

Dec 16, 2021
Cache library for golang. It supports expirable Cache, LFU, LRU and ARC.
Cache library for golang. It supports expirable Cache, LFU, LRU and ARC.

GCache Cache library for golang. It supports expirable Cache, LFU, LRU and ARC. Features Supports expirable Cache, LFU, LRU and ARC. Goroutine safe. S

Dec 30, 2022
Dec 28, 2022
Package cache is a middleware that provides the cache management for Flamego.

cache Package cache is a middleware that provides the cache management for Flamego. Installation The minimum requirement of Go is 1.16. go get github.

Nov 9, 2022
A mem cache base on other populator cache, add following feacture

memcache a mem cache base on other populator cache, add following feacture add lazy load(using expired data, and load it asynchronous) add singlefligh

Oct 28, 2021
Gin-cache - Gin cache middleware with golang

Gin-cache - Gin cache middleware with golang

Nov 28, 2022
An in-memory cache library for golang. It supports multiple eviction policies: LRU, LFU, ARC

GCache Cache library for golang. It supports expirable Cache, LFU, LRU and ARC. Features Supports expirable Cache, LFU, LRU and ARC. Goroutine safe. S

May 31, 2021
An in-memory key:value store/cache (similar to Memcached) library for Go, suitable for single-machine applications.

go-cache go-cache is an in-memory key:value store/cache similar to memcached that is suitable for applications running on a single machine. Its major

Dec 29, 2022
An in-memory key:value store/cache library written in Go 1.18 generics

go-generics-cache go-generics-cache is an in-memory key:value store/cache that is suitable for applications running on a single machine. This in-memor

Dec 27, 2022