You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
I want to create a bitmap cache (ie val bitmapCache = InMemoryKache<Int, Bitmap>).
If I run bitmapCache.get(1) I want to get the data. If it doesn't exist, it should automatically run a suspending function first, then return the value.
getOrPut theoretically does this, but I would have to tediously copy over the creationFunction function to all places where I want to get values.
Describe the solution you'd like
The Configuration could accept a factory lambda.
Describe alternatives you've considered
Define a lambda like this once, and reference it in all getOrPut calls:
val bitmapConstruction = { resId: Int ->
bitmapHelper.getBitmap(resId, context)
}
bitmapCache.getOrPut(R.drawable.xyz, bitmapConstruction)
Additional context LruCache has a way to override the create method to do just this. But it's written in Java and doesn't support coroutines etc.
The text was updated successfully, but these errors were encountered:
Thank you for your valuable feedback and suggestion. I think this feature is a good-to-have one and I'd think of ways to implement it in a future version.
I apologize for the late response for personal reasons.
Is your feature request related to a problem? Please describe.
I want to create a bitmap cache (ie
val bitmapCache = InMemoryKache<Int, Bitmap>
).If I run
bitmapCache.get(1)
I want to get the data. If it doesn't exist, it should automatically run a suspending function first, then return the value.getOrPut
theoretically does this, but I would have to tediously copy over thecreationFunction
function to all places where I want to get values.Describe the solution you'd like
The
Configuration
could accept a factory lambda.Describe alternatives you've considered
Define a lambda like this once, and reference it in all
getOrPut
calls:Additional context
LruCache
has a way to override thecreate
method to do just this. But it's written in Java and doesn't support coroutines etc.The text was updated successfully, but these errors were encountered: