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

Add ImageLoader.clearMemory(key) to clear a single memory cache item #55

Merged
merged 6 commits into from
Mar 29, 2020

Conversation

Goddchen
Copy link
Contributor

As discussed/requested by a user on Slack. Being able to clear a single item by its key from memory cache.

@colinrtwhite
Copy link
Member

Thanks for adding this. I want to spend a bit more time thinking about the design for the moment. This is a breaking change to the base ImageLoader interface which is pretty major.

Javieraeros
Javieraeros previously approved these changes Sep 5, 2019
…/memory-cache-clear-key

# Conflicts:
#	coil-base/src/main/java/coil/memory/MemoryCache.kt
@Goddchen
Copy link
Contributor Author

@Javieraeros merge conflicts resolved 👍

@mario
Copy link
Contributor

mario commented Jan 27, 2020

What do we do with this PR @colinrtwhite ?

@Goddchen
Copy link
Contributor Author

Merge? 😂

/**
* Remove a single item from memory cache.
*/
fun clearMemory(key: String)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we rename this to invalidate? The behaviour of this function is different enough from clearMemory() that it should probably have its own name. clearMemory() empties the bitmap pool as well as the memory cache whereas clearMemory(key) only removes a specific memory cache entry.

@colinrtwhite
Copy link
Member

colinrtwhite commented Jan 28, 2020

Sorry for the delay on this! @Goddchen left one comment. I'm planning to do a quick 0.9.3 release soon, but after that release + the PR feedback let's merge this in 🙂.

…che-clear-key

# Conflicts:
#	coil-base/src/main/java/coil/RealImageLoader.kt
#	coil-base/src/main/java/coil/memory/MemoryCache.kt
#	coil-base/src/test/java/coil/memory/MemoryCacheTest.kt
Merge branch 'master' of https://github.com/coil-kt/coil into feature/memory-cache-clear-key

# Conflicts:
#	coil-base/src/main/java/coil/memory/MemoryCache.kt
@Goddchen
Copy link
Contributor Author

@colinrtwhite merged coil/master, resolved conflicts and renamed the method as requested. I think it can be merged now 👍

@colinrtwhite
Copy link
Member

@Goddchen Awesome! Thanks for the contribution.

@colinrtwhite colinrtwhite merged commit 88082f6 into coil-kt:master Mar 29, 2020
colinrtwhite pushed a commit that referenced this pull request Oct 5, 2022
)

* Add ImageLoader.clearMemory(key) to clear a single memory cache item

* Add test for MemoryCache.clearMemory(key)

* Rename clearMemory(key) to invalidate(key)

Merge branch 'master' of https://github.com/coil-kt/coil into feature/memory-cache-clear-key

# Conflicts:
#	coil-base/src/main/java/coil/memory/MemoryCache.kt

* Update coil-base.api

Co-authored-by: Martin Liersch <[email protected]>
Co-authored-by: Goddchen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants