Git Product home page Git Product logo

atlantis's Introduction

Atlantis-Cache

Light-weight server-side caching solution for GraphQL.

GitHub license npm GitHub issues

About

Atlantis is a light-weight library that leverages Redis key-value store to dynamically cache GraphQL queries as responses. Atlantis is able to dynamically store deeply-nested queries and maintain the most recent and relevant data as mutations are made to the database. Queries that are more shallow and within the scope of previous queries are pulled directly from the cache, offering further flexibility and precision, without additional network requests or overriding previous key-values.

This package is meant to work in conjunction with Redis. For more information about Redis: check out: Redis

Getting Started

1. Installing and Connecting to a Redis Server

  • Mac-HomeBrew:

    • At the terminal, brew install redis
    • Start redis server with redis-server
    • Test if redis server is running: redis-cli ping. If it replies “PONG”, then it’s good to go!
    • Default port is 6379 (Keep note of the port)
  • Linux or non-Homebrew:

    • Download appropriate version of Redis from redis.io/download
    • Follow the instructions
    • Once installation is completed, start redis server with redis-server
    • Default port is 6379 (Keep note of the port)

2. Installing Atlantis-Cache

Install Atlantis-Cache as an npm module and save it to your package.json as a dependency.

npm i atlantis-cache

How to Use Atlantis-Cache

const express = require('express');
const redis = require('redis');
const { graphql } = require('graphql');
const schema = require('./schema/schema');
const { atlantis } = require('atlantis-cache');

const app = express();

// Configure your redis client
const redisClient = redis.createClient({
  host: 'localhost',
  port: 6379,
});

// Define your endpoint for graphQL queries and pass in your redis, and schema
app.use('/graphql', atlantis(redisClient, schema), async (req, res) => {
  return res.status(202).json({ data: res.locals.graphQLResponse });
});

Contributors:

License

This product is licensed under the MIT License - see the LICENSE.md file for details.‌

This product is accelerated by OS Labs.

atlantis's People

Contributors

settnaing199 avatar coralfussman avatar erik-matevosyan avatar erikjrogel avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.