Skip to content

Commit 677a2f7

Browse files
authored
Optimize Apigee entity caching for 3x branch (#1165)
1 parent 750cf44 commit 677a2f7

17 files changed

+139
-22
lines changed

apigee_edge.install

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,3 +389,17 @@ function apigee_edge_update_9002() {
389389
$edge_settings['content']['callbackUrl'] = $new_edge_settings['content']['callbackUrl'];
390390
$config_storage->write('core.entity_view_display.developer_app.developer_app.default', $edge_settings);
391391
}
392+
393+
/**
394+
* Set cache_insert_chunk_size for API Products, Developers, Developer apps.
395+
*/
396+
function apigee_edge_update_10401(): void {
397+
$configs = [
398+
'apigee_edge.api_product_settings',
399+
'apigee_edge.developer_settings',
400+
'apigee_edge.developer_app_settings',
401+
];
402+
foreach ($configs as $config) {
403+
\Drupal::configFactory()->getEditable($config)->set('cache_insert_chunk_size', 100)->save(TRUE);
404+
}
405+
}

config/install/apigee_edge.api_product_settings.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ langcode: en
22
entity_label_singular: ''
33
entity_label_plural: ''
44
cache_expiration: 900
5+
cache_insert_chunk_size: 100
56
access:
67
public:
78
- anonymous

config/install/apigee_edge.developer_app_settings.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ langcode: en
22
entity_label_singular: 'App'
33
entity_label_plural: 'Apps'
44
cache_expiration: 900
5+
cache_insert_chunk_size: 100
56
credential_lifetime: 0
67
locked_base_fields:
78
- displayName

config/install/apigee_edge.developer_settings.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,4 @@ user_edit_error_message:
2424
value: 'This email address already exists in our system. You can register a new account if you would like to use it on the Developer Portal.'
2525
format: 'plain_text'
2626
cache_expiration: 900
27+
cache_insert_chunk_size: 100

config/schema/apigee_edge.schema.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
apigee_edge.cache_insert_chunk_size:
2+
type: integer
3+
label: 'Cache insert chunk size'
4+
constraints:
5+
Range:
6+
min: 1
7+
18
apigee_edge.error_page:
29
type: config_object
310
label: 'Apigee Edge: Error page'
@@ -79,6 +86,8 @@ apigee_edge.developer_app_settings:
7986
label: 'How to refer to a Developer App on the UI (plural)'
8087
cache_expiration:
8188
type: integer
89+
cache_insert_chunk_size:
90+
type: apigee_edge.cache_insert_chunk_size
8291
required_base_fields:
8392
type: sequence
8493
sequence:
@@ -161,6 +170,8 @@ apigee_edge.developer_settings:
161170
label: 'Message'
162171
cache_expiration:
163172
type: integer
173+
cache_insert_chunk_size:
174+
type: apigee_edge.cache_insert_chunk_size
164175

165176
apigee_edge.api_product_settings:
166177
type: config_object
@@ -174,6 +185,8 @@ apigee_edge.api_product_settings:
174185
label: 'How to refer to an API Product on the UI (plural)'
175186
cache_expiration:
176187
type: integer
188+
cache_insert_chunk_size:
189+
type: apigee_edge.cache_insert_chunk_size
177190
access:
178191
type: mapping
179192
label: 'Filter displayed API products by access attribute'

modules/apigee_edge_teams/apigee_edge_teams.install

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,3 +233,16 @@ function apigee_edge_teams_update_9003() {
233233
$team_settings['enablefilter'] = $new_team_settings['enablefilter'];
234234
$config_storage->write('apigee_edge_teams.team_settings', $team_settings);
235235
}
236+
237+
/**
238+
* Set cache_insert_chunk_size for Teams and Team apps.
239+
*/
240+
function apigee_edge_teams_update_11401(): void {
241+
$configs = [
242+
'apigee_edge_teams.team_settings',
243+
'apigee_edge_teams.team_app_settings',
244+
];
245+
foreach ($configs as $config) {
246+
\Drupal::configFactory()->getEditable($config)->set('cache_insert_chunk_size', 100)->save(TRUE);
247+
}
248+
}

modules/apigee_edge_teams/config/install/apigee_edge_teams.team_app_settings.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ langcode: en
22
entity_label_singular: ''
33
entity_label_plural: ''
44
cache_expiration: 900
5+
cache_insert_chunk_size: 100
56
credential_lifetime: 0
67
locked_base_fields:
78
- displayName

modules/apigee_edge_teams/config/install/apigee_edge_teams.team_settings.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ enablefilter: ''
55
entity_label_singular: ''
66
entity_label_plural: ''
77
cache_expiration: 900
8+
cache_insert_chunk_size: 100
89
non_member_team_apps_visible_api_products:
910
- public
1011
- private

modules/apigee_edge_teams/config/schema/apigee_edge_teams.schema.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ apigee_edge_teams.team_settings:
1919
label: 'How to refer to a Team on the UI (plural)'
2020
cache_expiration:
2121
type: integer
22+
cache_insert_chunk_size:
23+
type: apigee_edge.cache_insert_chunk_size
2224
non_member_team_apps_visible_api_products:
2325
type: sequence
2426
sequence:
@@ -45,6 +47,8 @@ apigee_edge_teams.team_app_settings:
4547
label: 'How to refer to a Team App on the UI (plural)'
4648
cache_expiration:
4749
type: integer
50+
cache_insert_chunk_size:
51+
type: apigee_edge.cache_insert_chunk_size
4852
required_base_fields:
4953
type: sequence
5054
sequence:

modules/apigee_edge_teams/src/Entity/Storage/TeamAppStorage.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
use Drupal\Component\Datetime\TimeInterface;
2424
use Drupal\Core\Cache\CacheBackendInterface;
2525
use Drupal\Core\Cache\MemoryCache\MemoryCacheInterface;
26+
use Drupal\Core\Config\ConfigFactoryInterface;
2627
use Drupal\Core\Entity\EntityTypeInterface;
2728
use Drupal\apigee_edge\Entity\AppInterface;
2829
use Drupal\apigee_edge\Entity\Controller\AppControllerInterface;
@@ -72,11 +73,21 @@ class TeamAppStorage extends AppStorage implements TeamAppStorageInterface {
7273
* The app controller service.
7374
* @param \Drupal\apigee_edge\Entity\Controller\OrganizationControllerInterface $org_controller
7475
* The organization controller service.
76+
* @param \Drupal\Core\Config\ConfigFactoryInterface $config
77+
* Configuration factory.
7578
*/
76-
public function __construct(EntityTypeInterface $entity_type, CacheBackendInterface $cache_backend, MemoryCacheInterface $memory_cache, TimeInterface $system_time, TeamAppControllerFactoryInterface $team_app_controller_factory, AppControllerInterface $app_controller, OrganizationControllerInterface $org_controller) {
79+
public function __construct(EntityTypeInterface $entity_type, CacheBackendInterface $cache_backend, MemoryCacheInterface $memory_cache, TimeInterface $system_time, TeamAppControllerFactoryInterface $team_app_controller_factory, AppControllerInterface $app_controller, OrganizationControllerInterface $org_controller, protected ?ConfigFactoryInterface $config = NULL) {
7780
parent::__construct($entity_type, $cache_backend, $memory_cache, $system_time, $app_controller);
7881
$this->teamAppControllerFactory = $team_app_controller_factory;
7982
$this->orgController = $org_controller;
83+
if ($config === NULL) {
84+
@trigger_error('Calling ' . __METHOD__ . ' without the $config is deprecated in apigee_edge:3.0.12 and it will be required in apigee_edge:3.1.0. See https://github.com/apigee/apigee-edge-drupal/pull/1155.', E_USER_DEPRECATED);
85+
$config = \Drupal::configFactory();
86+
}
87+
88+
$config = $config->get('apigee_edge_teams.team_app_settings');
89+
$this->cacheExpiration = $config->get('cache_expiration');
90+
$this->cacheInsertChunkSize = $config->get('cache_insert_chunk_size') ?? static::DEFAULT_PERSISTENT_CACHE_INSERT_CHUNK_SIZE;
8091
}
8192

8293
/**
@@ -90,7 +101,8 @@ public static function createInstance(ContainerInterface $container, EntityTypeI
90101
$container->get('datetime.time'),
91102
$container->get('apigee_edge_teams.controller.team_app_controller_factory'),
92103
$container->get('apigee_edge.controller.app'),
93-
$container->get('apigee_edge.controller.organization')
104+
$container->get('apigee_edge.controller.organization'),
105+
$container->get('config.factory'),
94106
);
95107
}
96108

0 commit comments

Comments
 (0)