Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "wpckan",
"name": "opendevmekong/wpckan",
"version": "1.3.1",
"description": "wpckan is a wordpress plugin that exposes a series of functionalities to bring content stored in CKAN to Wordpress' UI and also provide mechanisms for archiving content generated on Wordpress into a CKAN instance.",
"repositories": [
Expand All @@ -13,10 +13,11 @@
}
],
"require": {
"psr/log": "1.1.4",
"silex/ckan_client": "dev-master",
"analog/analog": "dev-master",
"analog/analog": "1.0.16",
"twitter/typeahead.js": "dev-master",
"gilbitron/php-simplecache": "dev-master",
"doctrine/cache" : "*"
"doctrine/cache": "1.13.*"
}
}
8 changes: 5 additions & 3 deletions utils/datastore-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ function wpckan_get_or_cache($url,$id){
if (!$id) {
return wpckan_do_curl($url);
}

$json = "{}";
$hashed_id = "wpckan.".md5($id);

Expand All @@ -23,8 +23,10 @@ function wpckan_get_or_cache($url,$id){
$json = wpckan_do_curl($url);
}
if (!(strpos($json, '"success": false') !== false && !empty($hashed_id))) {
wpckan_log("Saving $url to cache");
$GLOBALS['cache']->save($hashed_id, $json, $GLOBALS['cache_time']);
if ($GLOBALS['cache'] !== null) {
wpckan_log("Saving $url to cache");
$GLOBALS['cache']->save($hashed_id, $json, $GLOBALS['cache_time']);
} else wpckan_log('cache is null');
}

return $json;
Expand Down
23 changes: 15 additions & 8 deletions wpckan.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,21 @@

$cache_path = $GLOBALS['wpckan_options']->get_option('wpckan_setting_cache_path');
$cache_time = $GLOBALS['wpckan_options']->get_option('wpckan_setting_cache_time');
if (defined('WP_REDIS_CACHE_HOST')){
$redis = new Redis();
$redis->pconnect(WP_REDIS_CACHE_HOST, WP_REDIS_CACHE_PORT);
$cache = new RedisCache();
$cache->setRedis($redis);
$GLOBALS['cache'] = $cache;
$GLOBALS['cache_time'] = $cache_time;
}
if (defined('WP_REDIS_CACHE_HOST')){
try {
if (!class_exists('Redis')) {
throw new Exception('Redis extension is not installed');
}
$redis = new Redis();
$redis->pconnect(WP_REDIS_CACHE_HOST, WP_REDIS_CACHE_PORT);
$cache = new RedisCache();
$cache->setRedis($redis);
$GLOBALS['cache'] = $cache;
$GLOBALS['cache_time'] = $cache_time;
} catch (Exception $e) {
error_log('WPCKAN Redis Error: ' . $e->getMessage());
}
}

if (!class_exists('wpckan')) {
class wpckan
Expand Down