View source: R/tw_write_search_to_cache.R
tw_write_search_to_cache | R Documentation |
Writes search to cache. Typically used internally, but exported to enable custom caching solutions.
tw_write_search_to_cache(
search_df,
type = "item",
language = tidywikidatar::tw_get_language(),
response_language = tidywikidatar::tw_get_language(),
cache = NULL,
overwrite_cache = FALSE,
cache_connection = NULL,
disconnect_db = TRUE
)
search_df |
A data frame with four columns typically generated with |
type |
Defaults to "item". Either "item" or "property". |
language |
Language to be used for the search. Can be set once per session with |
response_language |
Language to be used for the returned labels and descriptions. Corresponds to the |
cache |
Defaults to NULL. If given, it should be given either TRUE or FALSE. Typically set with |
overwrite_cache |
Defaults to FALSE. If TRUE, overwrites cache. |
cache_connection |
Defaults to NULL. If NULL, and caching is enabled, |
disconnect_db |
Defaults to TRUE. If FALSE, leaves the connection to cache open. |
Nothing, used for its side effects.
tw_set_cache_folder(path = fs::path(tempdir(), paste(sample(letters, 24), collapse = "")))
tw_create_cache_folder(ask = FALSE)
tw_disable_cache()
search_from_api <- tw_search(search = "Sylvia Pankhurst", include_search = TRUE)
search_from_cache <- tw_get_cached_search("Sylvia Pankhurst")
nrow(search_from_cache) == 0 # expect TRUE, as nothing has yet been stored in cache
tw_write_search_to_cache(search_df = search_from_api)
search_from_cache <- tw_get_cached_search("Sylvia Pankhurst")
search_from_cache
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.