-
Notifications
You must be signed in to change notification settings - Fork 201
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
Allow schema caching per server when using a common base schema #1224
base: 8.x-4.x
Are you sure you want to change the base?
Changes from all commits
c7a38e0
d99470d
bed2473
5ae3f29
b7d1f4c
0368ccf
8d1a98d
112fcf8
48c0b44
88c8e6c
2ec7f03
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,6 +44,13 @@ abstract class SdlSchemaPluginBase extends PluginBase implements SchemaPluginInt | |
*/ | ||
protected $inDevelopment; | ||
|
||
/** | ||
* The ID of the server using this plugin. | ||
* | ||
* @var string | ||
*/ | ||
protected $serverId; | ||
|
||
/** | ||
* The schema extension plugin manager. | ||
* | ||
|
@@ -111,6 +118,13 @@ public function __construct( | |
$this->moduleHandler = $moduleHandler; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function setServerId(string $serverId): void { | ||
$this->serverId = $serverId; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
* | ||
|
@@ -179,7 +193,7 @@ protected function getExtensions() { | |
*/ | ||
protected function getSchemaDocument(array $extensions = []) { | ||
// Only use caching of the parsed document if we aren't in development mode. | ||
$cid = "schema:{$this->getPluginId()}"; | ||
$cid = "server:{$this->serverId}:schema:{$this->getPluginId()}"; | ||
Comment on lines
-182
to
+196
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This assumes that the setter has always been called, but it might not have been, and Probably using a setter is not the best approach. Since the server ID is required for the plugin to work in the current it is essential that the setter is always called. The setter is not part of the Maybe we can add a |
||
if (empty($this->inDevelopment) && $cache = $this->astCache->get($cid)) { | ||
return $cache->data; | ||
} | ||
|
@@ -209,7 +223,7 @@ protected function getSchemaDocument(array $extensions = []) { | |
*/ | ||
private function getFullSchemaDocument(Schema $schema, array $extensions): ?DocumentNode { | ||
// Only use caching of the parsed document if we aren't in development mode. | ||
$cid = "full:{$this->getPluginId()}"; | ||
$cid = "server:{$this->serverId}:full:{$this->getPluginId()}"; | ||
if (empty($this->inDevelopment) && $cache = $this->astCache->get($cid)) { | ||
return $cache->data; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of using a setter to configure the server ID, I'm wondering if it wouldn't be better to make the plugin configurable by implementing
ConfigurableInterface
. In fact, both schema plugins we ship are already configurable (but the base classSdlSchemaPluginBase
isn't, and changing this would be a B/C break).