Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
acquia_connector-3312634
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Issue forks
acquia_connector-3312634
Commits
7036bb99
Commit
7036bb99
authored
2 years ago
by
Jakob P
Browse files
Options
Downloads
Patches
Plain Diff
DIT-512
: Cache the list of V3 indexes on acquia_connector-7.x-3.x (
#169
)
parent
bb2a3766
No related branches found
Branches containing commit
Tags
8.x-2.9
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
acquia_search/includes/AcquiaSearchSolrApi.php
+20
-2
20 additions, 2 deletions
acquia_search/includes/AcquiaSearchSolrApi.php
with
20 additions
and
2 deletions
acquia_search/includes/AcquiaSearchSolrApi.php
+
20
−
2
View file @
7036bb99
...
...
@@ -122,6 +122,13 @@ class AcquiaSearchSolrApi {
* Search indexes list.
*/
public
function
getIndexes
()
{
// Get data from cache.
$cid
=
'acquia_search.indexes.'
.
$this
->
subscription
;
if
((
$cache
=
cache_get
(
$cid
,
'cache'
))
&&
$cache
->
expire
>
REQUEST_TIME
)
{
return
$cache
->
data
;
}
$query
=
[
'network_id'
=>
$this
->
subscription
];
$nonce
=
AcquiaSearchSolrCrypt
::
randomBytes
(
24
);
$config_path
=
'/v2/index/configure'
;
...
...
@@ -147,17 +154,28 @@ class AcquiaSearchSolrApi {
$response
=
drupal_http_request
(
$url
,
$options
);
if
(
$response
->
code
>
300
||
!
isset
(
$response
->
data
))
{
$error_message
=
t
(
"Couldn't connect to
Solr
. Reason: @reason. Status code: @code. Request: @request"
,
[
$error_message
=
t
(
"Couldn't connect to
Acquia Search v3 to get list of cores
. Reason: @reason. Status code: @code. Request: @request"
,
[
'@reason'
=>
isset
(
$response
->
status_message
)
?
$response
->
status_message
:
''
,
'@code'
=>
isset
(
$response
->
code
)
?
$response
->
code
:
''
,
'@request'
=>
isset
(
$response
->
request
)
?
$response
->
request
:
''
,
]);
watchdog
(
'acquia_search_solr'
,
$error_message
,
[],
WATCHDOG_ERROR
);
// When API is not reachable, cache results for 1 minute.
$expire
=
REQUEST_TIME
+
60
;
cache_set
(
$cid
,
[],
'cache'
,
$expire
);
return
[];
}
return
$this
->
processResponse
(
$response
->
data
);
$result
=
$this
->
processResponse
(
$response
->
data
);
// Cache will be set in both cases, 1. when search v3 cores are found and
// 2. when there are no search v3 cores but api is reachable.
$expire
=
REQUEST_TIME
+
(
60
*
60
*
24
);
cache_set
(
$cid
,
$result
,
'cache'
,
$expire
);
return
$result
;
}
/**
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment