Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hint for storing data in localStorage #26

Open
adamritter opened this issue Jan 22, 2023 · 3 comments
Open

Hint for storing data in localStorage #26

adamritter opened this issue Jan 22, 2023 · 3 comments

Comments

@adamritter
Copy link
Owner

While having a LRU cache is a great idea, the most important queries are running permamently. Events generated by these queries need to be stored in localStorage even if they are not recent.

A simple API is RelayPool::store(evvent), Event::store(), and store(cb: OnEvent) : OnEvent .

localStorage should at least be updated before closing the window, but also probably a few second delay of debounce is probably good.

@adamritter
Copy link
Owner Author

Alternative storage is indexedb, maybe 2 entries are enough: 1 for hinted storage, other for LRU (though LRU can store 50MB, doesn't need to be super small, and can load slower, it's not a problem).

@adamritter
Copy link
Owner Author

Instead of the store function, a better hint is probably just the author pubkey and followed pubkeys.

This way caching can divide available space between author events, followed events and other events (40%, 40%, 20%???).

Divide the space between authors, and inside it between kinds.

Store freshest events.

This type of caching can be used in multiple stages (local, limited to 4MB, and larger cache that can be 50MB).

@adamritter
Copy link
Owner Author

Actually event author pubkey and division / space allocation are enough for these. Also all replies and reply profiles should be stored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant