Remove Storygraph API transient caching
This needs a better solution, because with so many people using the theme for community archives, this runs danger of becoming detrimental to performance rather than help.
This commit is contained in:
parent
ff47e6712c
commit
4b7a1333eb
@ -1603,7 +1603,6 @@ define( 'CONSTANT_NAME', value );
|
||||
| FICTIONEER_API_STORYGRAPH_IMAGES | boolean | Whether to add image links to the Storygraph. Default `true`.
|
||||
| FICTIONEER_API_STORYGRAPH_HOTLINK | boolean | Whether hotlinking images from the Storygraph is allowed. Default `false`.
|
||||
| FICTIONEER_API_STORYGRAPH_CHAPTERS | boolean | Whether to add chapters to the Storygraph `/stories` endpoint. Default `true`.
|
||||
| FICTIONEER_API_STORYGRAPH_TRANSIENTS | boolean | Whether to cache Storygraph responses as Transients. Default `true`.
|
||||
| FICTIONEER_ENABLE_STICKY_CARDS | boolean | Whether to allow sticky cards. Expensive. Default `true`.
|
||||
| FICTIONEER_ENABLE_STORY_DATA_META_CACHE | boolean | Whether to "cache" story data in a meta field. Default `true`.
|
||||
| FICTIONEER_ENABLE_MENU_TRANSIENTS | boolean | Whether to cache nav menus as Transients. Default `true`.
|
||||
|
@ -398,11 +398,6 @@ if ( ! defined( 'FICTIONEER_API_STORYGRAPH_CHAPTERS' ) ) {
|
||||
define( 'FICTIONEER_API_STORYGRAPH_CHAPTERS', true );
|
||||
}
|
||||
|
||||
// Boolean: Storygraph API Transients caching
|
||||
if ( ! defined( 'FICTIONEER_API_STORYGRAPH_TRANSIENTS' ) ) {
|
||||
define( 'FICTIONEER_API_STORYGRAPH_TRANSIENTS', true );
|
||||
}
|
||||
|
||||
// Boolean: Enable sticky cards
|
||||
if ( ! defined( 'FICTIONEER_ENABLE_STICKY_CARDS' ) ) {
|
||||
define( 'FICTIONEER_ENABLE_STICKY_CARDS', true );
|
||||
|
@ -310,15 +310,6 @@ if ( ! function_exists( 'fictioneer_api_request_story' ) ) {
|
||||
// Setup
|
||||
$story_id = absint( $data['id'] );
|
||||
|
||||
// Return cache if still valid
|
||||
if ( FICTIONEER_API_STORYGRAPH_TRANSIENTS ) {
|
||||
$transient_cache = get_transient( 'fictioneer_storygraph_story_' . $story_id );
|
||||
|
||||
if ( ! empty( $transient_cache ) ) {
|
||||
return rest_ensure_response( $transient_cache );
|
||||
}
|
||||
}
|
||||
|
||||
// Graph from story node
|
||||
$graph = fictioneer_api_get_story_node( $story_id );
|
||||
|
||||
@ -336,11 +327,6 @@ if ( ! function_exists( 'fictioneer_api_request_story' ) ) {
|
||||
// Request meta
|
||||
$graph['timestamp'] = current_time( 'U', true );
|
||||
|
||||
// Cache request
|
||||
if ( FICTIONEER_API_STORYGRAPH_TRANSIENTS ) {
|
||||
set_transient( 'fictioneer_storygraph_story_' . $story_id, $graph, FICTIONEER_API_STORYGRAPH_CACHE_TTL );
|
||||
}
|
||||
|
||||
// Response
|
||||
return rest_ensure_response( $graph );
|
||||
}
|
||||
@ -388,15 +374,6 @@ if ( ! function_exists( 'fictioneer_api_request_stories' ) ) {
|
||||
$page = max( absint( $data['page'] ) ?? 1, 1 );
|
||||
$graph = [];
|
||||
|
||||
// Return cache if still valid
|
||||
if ( FICTIONEER_API_STORYGRAPH_TRANSIENTS ) {
|
||||
$transient_cache = get_transient( 'fictioneer_storygraph_stories_' . $page );
|
||||
|
||||
if ( ! empty( $transient_cache ) ) {
|
||||
return rest_ensure_response( $transient_cache );
|
||||
}
|
||||
}
|
||||
|
||||
// Prepare query
|
||||
$query_args = array (
|
||||
'post_type' => 'fcn_story',
|
||||
@ -465,11 +442,6 @@ if ( ! function_exists( 'fictioneer_api_request_stories' ) ) {
|
||||
$graph['maxPages'] = $query->max_num_pages;
|
||||
$graph['timestamp'] = current_time( 'U', true );
|
||||
|
||||
// Cache request
|
||||
if ( FICTIONEER_API_STORYGRAPH_TRANSIENTS ) {
|
||||
set_transient( 'fictioneer_storygraph_stories_' . $page, $graph, FICTIONEER_API_STORYGRAPH_CACHE_TTL );
|
||||
}
|
||||
|
||||
return rest_ensure_response( $graph );
|
||||
}
|
||||
}
|
||||
|
@ -723,18 +723,6 @@ if ( ! function_exists( 'fictioneer_track_chapter_and_story_updates' ) ) {
|
||||
|
||||
// Refresh cached HTML output
|
||||
delete_transient( 'fictioneer_story_chapter_list_html' . $story_id );
|
||||
|
||||
// Delete cached API response
|
||||
if ( FICTIONEER_API_STORYGRAPH_TRANSIENTS ) {
|
||||
$count_stories = wp_count_posts( 'fcn_story' );
|
||||
$pages = $count_stories->publish / FICTIONEER_API_STORYGRAPH_STORIES_PER_PAGE + 1;
|
||||
|
||||
delete_transient( 'fictioneer_api_story_' . $story_id );
|
||||
|
||||
for ( $i = 1; $i <= $pages; $i++ ) {
|
||||
delete_transient( 'fictioneer_storygraph_stories_' . $i );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user