https://github.com/kamil-kubiczek/memcached-with-node
Express Node.js REST API with Memcached as cache
https://github.com/kamil-kubiczek/memcached-with-node
docker dummyjson express memcached rest-api winston-logger
Last synced: about 2 months ago
JSON representation
Express Node.js REST API with Memcached as cache
- Host: GitHub
- URL: https://github.com/kamil-kubiczek/memcached-with-node
- Owner: kamil-kubiczek
- Created: 2025-01-12T19:00:17.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-01-13T16:41:42.000Z (over 1 year ago)
- Last Synced: 2025-07-21T10:51:15.351Z (11 months ago)
- Topics: docker, dummyjson, express, memcached, rest-api, winston-logger
- Language: TypeScript
- Homepage:
- Size: 43 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## About project
Projects is example of small Node.js service which acts as REST API with custom in-memory database and memcached cache. **Feel free to use it as reference or fork it!**
Postman collection: [Endpoints collection](https://www.postman.com/restaurant-backend-developers-team/memcached-with-node)
## Installation
Use the npm package manager to install dependencies
```bash
npm i
```
Create docker container with memcached with **default port**
```bash
docker run --name my-memcached -d memcached
```
## Run
```bash
npm run start
```
## How it works
Every time client requests Express API cached endpoint, API searches for cached query in memcached. If it's available it's returned, if not, it's downloaded from artificially slowed in-memory database and cached again in background. If you run API you will see if some data was cached or not (CACHE HIT/MISS) inside logs.
Here's flowchart of process:
```mermaid
flowchart TD
A["Express API"] <--> n1["Memcached container"] & n2["In-memory database"]
n3["Client"] <--> A
n3@{ shape: rect}
style A stroke:#2962FF
style n1 stroke:#00C853
style n2 stroke:#FFD600
style n3 stroke:#616161
```