From 17c1f4f4d0bdcabdb81b55b2f2684d2617b57688 Mon Sep 17 00:00:00 2001
From: Ere Maijala <ere.maijala@helsinki.fi>
Date: Fri, 4 Sep 2020 14:10:35 +0300
Subject: [PATCH] KohaRest: Use proper cache for items. (#1705)

---
 module/VuFind/src/VuFind/ILS/Driver/KohaRest.php | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/module/VuFind/src/VuFind/ILS/Driver/KohaRest.php b/module/VuFind/src/VuFind/ILS/Driver/KohaRest.php
index d5698bb6c9d..35de8713fde 100644
--- a/module/VuFind/src/VuFind/ILS/Driver/KohaRest.php
+++ b/module/VuFind/src/VuFind/ILS/Driver/KohaRest.php
@@ -1994,12 +1994,14 @@ class KohaRest extends \VuFind\ILS\Driver\AbstractBase implements
      */
     protected function getItem($id)
     {
-        static $cachedRecords = [];
-        if (!isset($cachedRecords[$id])) {
+        $cacheId = "items|$id";
+        $item = $this->getCachedData($cacheId);
+        if (null === $item) {
             $result = $this->makeRequest(['v1', 'items', $id]);
-            $cachedRecords[$id] = $result['data'] ?? false;
+            $item = $result['data'] ?? false;
+            $this->putCachedData($cacheId, $item, 300);
         }
-        return $cachedRecords[$id];
+        return $item ?: null;
     }
 
     /**
-- 
GitLab