Giter Club home page Giter Club logo

eager_cache's Introduction

Eager Cache

Magic Shia Labeouf GIFal eager caching server.

Powered by FastAPI.

Deploying

There is a dockerfile, dockercompose and k8s yamls.

Make sure you have a running redis deployment, set to notify keyspace events:

redis-cli config set notify-keyspace-events Ex

What is eager caching?

Say you have some data that you need to serve to your users. You decide to use a cache, but then you realise you need also to invalidate the cache after some time. Another consideration you tak into account is serving your users with fresh information every time they want to access the data, using the cache.

Introducing eager-cache: In its base, it's a FastAPI server that uses supplied fetchers in order to serve users with information they need. It's actually a key-value store, storing cache in redis for each request (path+query) the value retrieved from the appropriate fetcher.

The magic is in the caching mechanism. It uses redis in order to store the cached responses, and sets ttl for every cache record using a shadow key for each record.

There is a microservice that subscribes to keyspace events from the redis deployment and refetches the expired value using the fetcher.

DataItem

In addition to storing the data, DataItem does two important things:

First, it stores the time the data itself was fetched (this is last_retrieved).

Second, it stores the time the data itself was changed (this is last_modified).

This way, you can always know when was the data fetched, but also when was it changed (the comparison is done using deepdiff)

eager_cache_uml

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.