Added redis to load
This commit is contained in:
@@ -30,3 +30,7 @@ defined('SHOW_DEBUG_BACKTRACE') || define('SHOW_DEBUG_BACKTRACE', true);
|
|||||||
| items. It can always be used within your own application too.
|
| items. It can always be used within your own application too.
|
||||||
*/
|
*/
|
||||||
defined('CI_DEBUG') || define('CI_DEBUG', true);
|
defined('CI_DEBUG') || define('CI_DEBUG', true);
|
||||||
|
|
||||||
|
define('ENV_ID', 'DEVLP20233103-A3');
|
||||||
|
define('HOME_PAGE_BACKGROUND', 'api_bk.jpg');
|
||||||
|
define('CACHE_DOMAIN', 'wrench.dev');
|
||||||
@@ -19,3 +19,7 @@ error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_USER_NOTICE &
|
|||||||
| release of the framework.
|
| release of the framework.
|
||||||
*/
|
*/
|
||||||
defined('CI_DEBUG') || define('CI_DEBUG', false);
|
defined('CI_DEBUG') || define('CI_DEBUG', false);
|
||||||
|
|
||||||
|
define('ENV_ID', 'PRAODUCTIONG20233103-A3');
|
||||||
|
define('HOME_PAGE_BACKGROUND', 'api_bk.jpg');
|
||||||
|
define('CACHE_DOMAIN', 'wrench.prod');
|
||||||
@@ -30,3 +30,7 @@ defined('SHOW_DEBUG_BACKTRACE') || define('SHOW_DEBUG_BACKTRACE', true);
|
|||||||
| release of the framework.
|
| release of the framework.
|
||||||
*/
|
*/
|
||||||
defined('CI_DEBUG') || define('CI_DEBUG', true);
|
defined('CI_DEBUG') || define('CI_DEBUG', true);
|
||||||
|
|
||||||
|
define('ENV_ID', 'TESTING20233103-A3');
|
||||||
|
define('HOME_PAGE_BACKGROUND', 'api_bk.jpg');
|
||||||
|
define('CACHE_DOMAIN', 'wrench.test');
|
||||||
@@ -22,7 +22,7 @@ class Cache extends BaseConfig
|
|||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $handler = 'file';
|
public $handler = 'redis';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
@@ -35,7 +35,7 @@ class Cache extends BaseConfig
|
|||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $backupHandler = 'dummy';
|
public $backupHandler = 'file';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
@@ -153,11 +153,12 @@ class Cache extends BaseConfig
|
|||||||
* @var array<string, int|string|null>
|
* @var array<string, int|string|null>
|
||||||
*/
|
*/
|
||||||
public $redis = [
|
public $redis = [
|
||||||
'host' => '127.0.0.1',
|
'host' => '10.0.0.32',
|
||||||
'password' => null,
|
'password' => '7f079034e166ecf52d82cbec9876e4dc8a154b0c37248f3fa1734d4eeab938d5',
|
||||||
'port' => 6379,
|
'port' => 6378,
|
||||||
'timeout' => 0,
|
'timeout' => 0,
|
||||||
'database' => 0,
|
'database' => 0,
|
||||||
|
'prefix' => 'WRB',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -77,6 +77,25 @@ class Database extends Config
|
|||||||
'foreignKeys' => true,
|
'foreignKeys' => true,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public $wrench_blog = [
|
||||||
|
'DSN' => '',
|
||||||
|
'hostname' => '10.10.33.60',
|
||||||
|
'username' => 'float',
|
||||||
|
'password' => 'float.user',
|
||||||
|
'database' => 'float_blog',
|
||||||
|
'DBDriver' => 'MySQLi',
|
||||||
|
'DBPrefix' => '',
|
||||||
|
'pConnect' => false,
|
||||||
|
'DBDebug' => (ENVIRONMENT !== 'production'),
|
||||||
|
'charset' => 'utf8',
|
||||||
|
'DBCollat' => 'utf8_general_ci',
|
||||||
|
'swapPre' => '',
|
||||||
|
'encrypt' => false,
|
||||||
|
'compress' => false,
|
||||||
|
'strictOn' => false,
|
||||||
|
'failover' => [],
|
||||||
|
'port' => 3306,
|
||||||
|
];
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Controllers;
|
||||||
|
|
||||||
|
class WrenchApi extends BaseController
|
||||||
|
{
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
$data['envID'] = getenv('ENV_ID');
|
||||||
|
$data['home_background'] = getenv('HOME_PAGE_BACKGROUND');
|
||||||
|
return view('welcome_message',$data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,74 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Controllers;
|
||||||
|
|
||||||
|
//use CodeIgniter\API\ResponseTrait;
|
||||||
|
|
||||||
|
class WrenchBlog extends BaseController
|
||||||
|
{
|
||||||
|
|
||||||
|
//use ResponseTrait;
|
||||||
|
|
||||||
|
protected $db;
|
||||||
|
public $con_name = 'wrench_blog';
|
||||||
|
|
||||||
|
private function apiData() {
|
||||||
|
$this->db = \Config\Database::connect($this->con_name);
|
||||||
|
$data = array();
|
||||||
|
|
||||||
|
try {
|
||||||
|
$mysql = "SELECT id, post_title, post_content,post_date,comment_count FROM wp_posts WHERE post_type='post' AND post_status = 'publish' ORDER BY post_date DESC LIMIT 9";
|
||||||
|
$mysql = "SELECT p1.id AS id, p1.*, wm2.meta_value FROM wp_posts p1 LEFT JOIN wp_postmeta wm1
|
||||||
|
ON (wm1.post_id = p1.id AND wm1.meta_value IS NOT NULL AND wm1.meta_key = '_thumbnail_id' )
|
||||||
|
LEFT JOIN
|
||||||
|
wp_postmeta wm2
|
||||||
|
ON (wm1.meta_value = wm2.post_id AND wm2.meta_key = '_wp_attached_file' AND wm2.meta_value IS NOT NULL )
|
||||||
|
WHERE
|
||||||
|
p1.post_status='publish'
|
||||||
|
AND p1.post_type='post'
|
||||||
|
ORDER BY p1.post_date DESC LIMIT 2000";
|
||||||
|
|
||||||
|
$query = $this->db->query($mysql);
|
||||||
|
|
||||||
|
$data['payload']['blogdata'] = $query->getResult('array');
|
||||||
|
$totalCount = count( $data['payload']['blogdata'] );
|
||||||
|
|
||||||
|
$randomIndex = rand(1, $totalCount);
|
||||||
|
|
||||||
|
$data['payload']['featured'] = $data['payload']['blogdata'][$randomIndex ];
|
||||||
|
$data['payload']['image_url'] = 'https://blog.float.sg/wp-content/uploads/';
|
||||||
|
$data['payload']['blog_url'] = 'https://blog.float.sg/';
|
||||||
|
$data['payload']['total'] = $totalCount;
|
||||||
|
} catch (Exception $ex) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function blogData($endpoint,$raw_array)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
$rawData = $this->apiData();
|
||||||
|
// $res1= $rawData[0]['payload'];
|
||||||
|
$res1= $rawData; //[0]['payload'];
|
||||||
|
$this->saveCache('blogdata',$res1['payload']);
|
||||||
|
*/
|
||||||
|
|
||||||
|
$res1 = $this->getCache($endpoint);
|
||||||
|
if (count($res1)==0){
|
||||||
|
$rawData = $this->apiData();
|
||||||
|
$res1= $rawData['payload']; //[0]['payload'];
|
||||||
|
$this->saveCache($endpoint,$res1);
|
||||||
|
}
|
||||||
|
//$resJson = $this->response->setJson($res1);
|
||||||
|
return $res1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user