Coder Social home page Coder Social logo

backbone-api-client-redis's Issues

Implement `stale-fresh-cache`

While request-redis-cache is great, it is a little too naive. I would love to support stale-fresh-cache which is intended to work via:

Let's work with an example TTL (fresh = 30 minutes, stale = 60 minutes).

If we have no cached information, get it and cache it for 60 minutes.

If there is cached information, send back whatever we have.

In addition, check the TTL. If the TTL is over 30 minutes (e.g. the cache has turned stale), fetch the information in the background and update our cache.

The benefit to this mechanism is it prevents completely running out of data to serve without sacrificing performance. Additionally, it guarantees the data will expire at some point. However, it is still possible to cache stampede =/

Contemplate alternative integrations into `backbone-api-client`

Currently, it is a little annoying that we more/less lock in callApiClient functionality before allowing caching mixin. Should we be doing this and is there a better way (e.g. via sync overrides)?

For reference, we are currently structuring it this way to pick up changes from adjustApiClientOptions which could affect parameters and thus the hash for the request. We want the hash to be as sensitive to what is actually sent out/important as possible.

Add caching of create/save data

Currently, we only cache read responses and invalidate on everything else. However, some server support sending back the resource upon create/update. As a result, we should cache/serve that data.

Unfortunately, we guarantee requests are stored against the hash of their request options. As a result, it is impossible for us to predict what save data would line up with, if at all.

Additionally, this hash is used to switch between server upgrades easily (e.g. new attributes on request options).

Please discuss possible options in this thread.

Expose `clearCache` method

Sometimes, actions at one-off endpoints affect your data. While this is non-atomic and disgusting itself, it happens. To make sure we keep our cache accurate at these points, we should expose the cache deletion logic from callApiClient as clearCache.

clearCache(method, options, cb);

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.