Skip to content

Extend ConvexQueryCacheProvider with a "storer" object #677

@frozar

Description

@frozar

This is not a bug report but rather a discussion of a potential feature regarding the ConvexQueryCacheProvider component.

I'm well aware that the cache provided by this component is not just about data, but rather about keeping the subscription to the central DB in sync with queries (as far as I understood).

My question is: Is it possible to add an optional argument to the ConvexQueryCacheProvider contructor to provide an object, storer for example, which would be able to read and to write from a storage?
The type of this storer object should be something like:

type Storer = {
  fnRead: (key: string) => Promise<any>;
  fnWrite: (key: string, value: any) => Promise<void>;
};

The fnRead function should be used when a query is done by the client application in case this query has no active subscription or the DB is unreachable.
The fnWrite function should be used when a query is done by the client application in case this query has an active subscription or the DB is reachable.

The purpose is to be able to provide data to the application in case of connection disability. This would be particularly interesting on a mobile phone when sometime, you're in place without internet connection. What interest me the most is to be able to have some data when my application opens up, even if I'm in a mall without internet connection.
Also, this management of the cache concerns only the read part of the interaction with the DB, so no headheck with optimistic write and resolution of the state of the DB when devices get back to an internet connection.

To me, it seems possible to do from ConvexQueryCacheProvider component and harmless. The optionality of this argument should not break existing code. And finally, with this interface, ConvexQueryCacheProvider is agnostic about the storage system eventually used by the application.

Does this request seem legit to you?
It is implementable without directly interacting with the BaseConvexClient component?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions