Skip to content

Commit 3360cf4

Browse files
committed
1.7.0 Release
Add configurable cache TTL
1 parent 4e4093b commit 3360cf4

File tree

4 files changed

+8
-3
lines changed

4 files changed

+8
-3
lines changed

src/Model/Api/ApiAbstract.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ protected function _request($route, $params = [])
172172
throw new ApiException($e->getMessage(), $e->getCode(), $e);
173173
}
174174

175-
$this->cache->save(str($response), $cacheKey, [], 3600 * 24);
175+
$this->cache->save(str($response), $cacheKey, [], $this->scopeConfig->getValue('skywire_wordpress_api/api/cache_ttl'));
176176

177177
return $response;
178178
}

src/etc/adminhtml/system.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,14 @@
2929
<label>Username</label>
3030
<comment>HTTP Auth Username</comment>
3131
</field>
32-
<field id="password" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
32+
<field id="password" translate="label" type="text" sortOrder="25" showInDefault="1" showInWebsite="1" showInStore="1">
3333
<label>Password</label>
3434
<comment>HTTP Auth Password</comment>
3535
</field>
36+
<field id="cache_ttl" translate="label" type="text" sortOrder="30" showInDefault="1">
37+
<label>Cache Lifetime</label>
38+
<comment>Cache TTL in seconds</comment>
39+
</field>
3640
</group>
3741
<group id="pagination" translate="label" type="text" sortOrder="20" showInDefault="1">
3842
<label>Category Pagination</label>

src/etc/config.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<path>/wp-json/wp/v2</path>
88
<sub_dir>blog</sub_dir>
99
<nav_name>Blog</nav_name>
10+
<cache_ttl>86400</cache_ttl>
1011
</api>
1112
<pagination>
1213
<posts_per_page>10</posts_per_page>

src/etc/module.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0"?>
22
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
3-
<module name="Skywire_WordpressApi" setup_version="1.6.0">
3+
<module name="Skywire_WordpressApi" setup_version="1.7.0">
44
</module>
55
</config>

0 commit comments

Comments
 (0)