Skip to content

caching strategy

Marcus Hitchins edited this page Mar 29, 2018 · 6 revisions

After trying out lots of different caching strategies and being frustrated by them. Here is a way that will give us the flexibility we need. (and won't annoy me)

I'm thinking the caching strategy could be an object with this structure:

  • cache
    • path
      • event / true / false
        • seconds / true / false
  • sync
    • path
      • event / true / false
        • seconds / true / false

"path"

a dot(.) separated list of alphanumeric characters and anything that starts with that it an empty string signifies default

"event"

notWrittenToFor, notReadFromIn, login, logout, share, close, afterSuccessfulSync

example:

{
  cache: {
    "user.email": false,
    "analytics": {
      afterSuccessfulSync: false,
      logout: false,
    },
    "shares": {
      notReadFromIn: 432000,
    },
  },
  sync:
    "analytics": {
      afterSuccessfulSync: 300, 
      logout: true,
    },
  },
}

in this example: Will not cache the user's email. The analytics will only be sent every 5 minutes unless the user is logging out When the analytics have been successfully sunk they will be deleted from the cache. If the share hasn't been read for five days it will be deleted from the cache.

Everything else will be cache indefinitely and sync immediately (on idle).

p.s. In the future as well as cache and sync I'd like to add decrypt and encrypt

Clone this wiki locally