-
Notifications
You must be signed in to change notification settings - Fork 25
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
Provide custom cache key #80
Comments
I think you can make your own mapper to do that, if I understand correctly. |
I'm looking at https://github.com/Kamel-Media/Kamel/blob/main/kamel-core/src/commonJvmMain/kotlin/io/kamel/core/mapper/JvmMappers.kt as an example and that just looks like the translation of the URL, but no ability to do some background processing when the image does not yet exist in cache unless I'm misunderstanding how it works. I'm building some website image previews, so I'm looking to be able to feed it a base url (eg; github.com) and if that key exists in cache already, then it will pull the cached image. If not, then I can get a callback of some sort where I can go parse that website to pull out the image I want such as og:image or something similar, and then download that image but cache it under the original base url so I only have to parse website html once. |
https://zqtemp.oss-cn-beijing.aliyuncs.com/wangfou/%E9%98%BF%E5%87%A1%E8%BE%BE-%E6%89%93%E5%85%A5%E6%95%8C%E4%BA%BA%E5%86%85%E9%83%A8.png?Expires=1716017708&OSSAccessKeyId=TMP.3KhCE8dmmQEanAj2LaKPxR6Eb6QE6hAYThZgSTEyM5ATrbGMVgQx5Rc8c31Qp9theDKSoYPwyQ11EhzrV5qedbNx6AmQhR&Signature=utYM9r7kpGEEfR1qMTYJZYhoc%2B4%3D 这是阿里云的oss在设置私有读写之后,都会带着?Expires=1716017708&OSSAccessKeyId=TMP.3KhCE8dmmQEanAj2LaKPxR6Eb6QE6hAYThZgSTEyM5ATrbGMVgQx5Rc8c31Qp9theDKSoYPwyQ11EhzrV5qedbNx6AmQhR&Signature=utYM9r7kpGEEfR1qMTYJZYhoc%2B4%3D 后缀,为了保证我们能够获这个资源我们需要每次都带着后缀,后缀的时间是变化的,所以 kamelImage 每次都会拉取新的图片数据,但是 这张图片的https://zqtemp.oss-cn-beijing.aliyuncs.com/wangfou/%E9%98%BF%E5%87%A1%E8%BE%BE-%E6%89%93%E5%85%A5%E6%95%8C%E4%BA%BA%E5%86%85%E9%83%A8.png 这部分是不变的,这个不变的地址可以作为缓存的key,所以需要一个可以自定义设置缓存Key的功能,请问有这样的功能吗 ,如果没有可以考虑开发吗 |
I was reading through the code but didn't see an example, is it possible to provide a custom key value for the cache to Kamel? If not, can this be a feature request?
In my use case I'm looking to be able to feed it a http url for something that isn't an image and if that url key exists in cache, then load it, if not then I will provide a method that takes that url and returns a url to an actual image for it to go load - but then it needs to be cached under the other URL.
Is it possible to give Kamel a custom cache k/v pair class where I could implement this and get some kind of onNotInCache method where I can return the real img url?
The text was updated successfully, but these errors were encountered: