https://github.com/andyj/cached-queries-with-nodejs
Playing around with replicating caching of queries
https://github.com/andyj/cached-queries-with-nodejs
Last synced: 7 months ago
JSON representation
Playing around with replicating caching of queries
- Host: GitHub
- URL: https://github.com/andyj/cached-queries-with-nodejs
- Owner: andyj
- License: unlicense
- Created: 2024-06-14T18:42:58.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-12-27T05:11:37.000Z (over 1 year ago)
- Last Synced: 2025-01-16T22:23:21.708Z (over 1 year ago)
- Language: JavaScript
- Size: 247 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Cached Queries With Nodejs
I'm still a CFML coder at heart, so this is a personal project to replicate something similar to CFML Query Caching. It demonstrates how to set up a Node.js application with a RDBMS (SQLite3 for now) and Redis for caching query results. Each user’s query results are cached uniquely based on their user ID and query parameters. This setup aims to replicate caching of queries.
## Environment Setup
Create a `.env` file in the root of your project with the following content. This file will store your Redis connection details securely.
```plaintext
# .env
# The hostname or IP address of your Redis server
REDISHOST="localhost"
# The port number on which your Redis server is running
REDISPORT="6379"
# The password for your Redis server (if applicable)
REDISPW="passwd"
```
## Installation
1. **Clone the repository:**
```bash
git clone https://github.com/andyj/cached-queries-with-nodejs.git
cd cached-queries-with-nodejs
```
2. **Install the dependencies:**
```bash
npm install
```
## Running the Application
1. **Start the server:**
```bash
npm start
```
2. **Access the example route:**
- Open your browser and navigate to `http://localhost:8001/data`.
3. **Output**
- The output should be a time stamp `[{"time()":"09:38:46"}]` which does not change for 5 seconds.