Closed yuans-cellbio closed 3 months ago
Looking at the {memoise}
documentation I suspect the following might work now to clear the cache:
memoise::forget(gridpattern:::img_read_memoised)
Do this every time the local image files are changed.
{gridpattern}
's image pattern uses an internal function img_read_memoised
which is a "memoised" function to read images that uses the {memoise}
package (this functionality is extracted from an older version of {ggpattern}
).
In particular this means if you are using an image from a website (filename is a URL) you won't keep hitting that website over and over. In particular this is useful for the "placeholder" pattern which auto-grabs images from various "placeholder" websites.
Because we want to be respectful to the bandwidth of the placeholder websites (and other websites) I'm not entirely sure I want to change this behavior as a default. But maybe document/make easier to clear the cache?
- Looking at the
{memoise}
documentation I suspect the following might work now to clear the cache:memoise::forget(gridpattern:::img_read_memoised)
Do this every time the local image files are changed.{gridpattern}
's image pattern uses an internal functionimg_read_memoised
which is a "memoised" function to read images that uses the{memoise}
package (this functionality is extracted from an older version of{ggpattern}
).- In particular this means if you are using an image from a website (filename is a URL) you won't keep hitting that website over and over. In particular this is useful for the "placeholder" pattern which auto-grabs images from various "placeholder" websites.
- Because we want to be respectful to the bandwidth of the placeholder websites (and other websites) I'm not entirely sure I want to change this behavior as a default. But maybe document/make easier to clear the cache?
memoise::forget(gridpattern:::img_read_memoised) worked like a charm.
I agree that the current image caching can be helpful when sourcing images from websites. Some more documentation is perfect.
Thank you for the cool package! It's not useless at all.
Development version of {gridpattern}
now exports reset_image_cache()
which resets the cache used by the "image" and "placeholder" patterns.
I want to geom_col_pattern + scale_pattern_file_discrete or _manual to create well-aligned image tiles in R markdown. My goal is to edit the source images (crop, offset, etc.) so that I can generate different image tiles using the same code.
However, I noticed that if I use the same image file name after editing, the next plot generated still uses the old image. Even if you delete the referred images locally, the code still runs and generates the same plot.
I think ggpattern retrieves cached images when it sees the same file names. It runs correctly after restarting Rstudio or when knitted.
Here is an example.
Session info