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

[Feature Request] An ability to add entry to the cache manually #535

Open
alaegin opened this issue Mar 12, 2023 · 0 comments
Open

[Feature Request] An ability to add entry to the cache manually #535

alaegin opened this issue Mar 12, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@alaegin
Copy link

alaegin commented Mar 12, 2023

Hello!

Is your feature request related to a problem? Please describe.
I think that my case is very common. Therefore I couldn't create a clean solution without library extension and/or excessive complexity.

I have two screens:

  • Posts list. I fetch List<Post> here.
  • Post details list. It's opened after the post item on the previous screen is clicked. It has the same data type Post.

My goal is to be able to receive an exact Post by its UUID (String) from the store.

Describe the solution you'd like
I'd like to be able to add an entry to the cache without making network requests.
In my particular case I see the following block of code:

val postsResult = dataSource.getPosts(page = postsPage)

postsResult.ifSuccess { posts: List<Post> ->
    posts.forEach { post: Post -> postsStore.put(post.id, post) }
}

Perhaps there is already another solution that I don't see?

Describe alternatives you've considered

  • I could create SourceOfTruth based on Map. It seems weird to have a Store with cache functionality and then disable, and implement own cache just it in order to have just put logic.
  • I could create any database for persisting List but it seems too complex because there's no point in persistence in my particular case because data changes frequently.

P.S. I've tried to implement this logic in 5.0.0-alpha04.

@alaegin alaegin added the enhancement New feature or request label Mar 12, 2023
@alaegin alaegin changed the title [Feature Request] An ability to add entry to the cache [Feature Request] An ability to add entry to the cache manually Mar 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: 🆕 Triage
Development

No branches or pull requests

1 participant