Redis updates
This commit is contained in:
+12
-5
@@ -22,7 +22,7 @@ class Cache extends BaseConfig
|
|||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $handler = 'file';
|
public $handler = 'redis'; //'file';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
@@ -35,7 +35,7 @@ class Cache extends BaseConfig
|
|||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $backupHandler = 'dummy';
|
public $backupHandler = 'file';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
@@ -152,14 +152,21 @@ class Cache extends BaseConfig
|
|||||||
*
|
*
|
||||||
* @var array<string, int|string|null>
|
* @var array<string, int|string|null>
|
||||||
*/
|
*/
|
||||||
public $redis = [
|
public $redis2 = [
|
||||||
'host' => '127.0.0.1',
|
'host' => '10.0.0.112',
|
||||||
'password' => null,
|
'password' => 'adae59706edf22f9f61180578cd16cc2038703c7230ae012e3c783ace1d09d64',
|
||||||
'port' => 6379,
|
'port' => 6379,
|
||||||
'timeout' => 0,
|
'timeout' => 0,
|
||||||
'database' => 0,
|
'database' => 0,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public $redis = [
|
||||||
|
'host' => '10.0.0.32',
|
||||||
|
'password' => '7f079034e166ecf52d82cbec9876e4dc8a154b0c37248f3fa1734d4eeab938d5',
|
||||||
|
'port' => 6378,
|
||||||
|
'timeout' => 0,
|
||||||
|
'database' => 0,
|
||||||
|
];
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
* Available Cache Handlers
|
* Available Cache Handlers
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ $routes->setAutoRoute(true);
|
|||||||
$routes->get('/', 'Home::index');
|
$routes->get('/', 'Home::index');
|
||||||
$routes->get('/wp/', 'Dengine::index');
|
$routes->get('/wp/', 'Dengine::index');
|
||||||
|
|
||||||
$routes->get('/en/floatweb/api/v1/blogdata/', 'FloatWeb::index');
|
$routes->get('/en/floatweb/api/v1/blogdata/', 'FloatWeb::blogData');
|
||||||
|
|
||||||
|
|
||||||
//CHIEFSOFT WEBSITE
|
//CHIEFSOFT WEBSITE
|
||||||
|
|||||||
@@ -5,12 +5,15 @@ namespace App\Controllers;
|
|||||||
|
|
||||||
|
|
||||||
use CodeIgniter\API\ResponseTrait;
|
use CodeIgniter\API\ResponseTrait;
|
||||||
|
use CodeIgniter\Cache\CacheInterface;
|
||||||
|
|
||||||
class FloatWeb extends BaseController
|
class FloatWeb extends BaseController
|
||||||
{
|
{
|
||||||
use ResponseTrait;
|
use ResponseTrait;
|
||||||
|
|
||||||
protected $db;
|
protected $db;
|
||||||
|
|
||||||
|
|
||||||
public $con_name = 'float_blog';
|
public $con_name = 'float_blog';
|
||||||
private function apiData() {
|
private function apiData() {
|
||||||
$this->db = \Config\Database::connect($this->con_name);
|
$this->db = \Config\Database::connect($this->con_name);
|
||||||
@@ -520,23 +523,53 @@ variations from the norm, and in addition other reproductive organ issue
|
|||||||
public function blogData()
|
public function blogData()
|
||||||
{
|
{
|
||||||
$rawData = $this->apiData();
|
$rawData = $this->apiData();
|
||||||
$res1= $rawData[0]['payload'];
|
// $res1= $rawData[0]['payload'];
|
||||||
|
$res1= $rawData; //[0]['payload'];
|
||||||
// var_dump($res1);
|
$this->runCache('blogdata',$res1['payload']);
|
||||||
|
$resJson = $this->response->setJson($res1);
|
||||||
return $this->response->setJson($res1);
|
return $resJson;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function runCache($cacheKey,$data){
|
||||||
|
$cache = \Config\Services::cache();
|
||||||
|
if (! $foo = cache($cacheKey)) {
|
||||||
|
echo 'Saving to the cache!<br>';
|
||||||
|
cache()->save($cacheKey, $this->data_stringify($data), 3000);
|
||||||
|
}
|
||||||
|
// $foo = $cache->get('foo');
|
||||||
|
}
|
||||||
|
|
||||||
|
private function data_stringify($data) {
|
||||||
|
switch (gettype($data)) {
|
||||||
|
case 'string' : return '\''.addcslashes($data, "'\\").'\'';
|
||||||
|
case 'boolean': return $data ? 'true' : 'false';
|
||||||
|
case 'NULL' : return 'null';
|
||||||
|
case 'object' :
|
||||||
|
case 'array' :
|
||||||
|
$expressions = [];
|
||||||
|
foreach ($data as $c_key => $c_value) {
|
||||||
|
$expressions[] = $this->data_stringify($c_key).' => '.
|
||||||
|
$this->data_stringify($c_value);
|
||||||
|
}
|
||||||
|
return gettype($data) === 'object' ?
|
||||||
|
'(object)['.implode(', ', $expressions).']' :
|
||||||
|
'['.implode(', ', $expressions).']';
|
||||||
|
default: return (string)$data;
|
||||||
|
}
|
||||||
|
}
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
$rawData = $this->apiData();
|
// $rawData = $this->apiData();
|
||||||
// $res1= $rawData[0]['payload'];
|
// // $res1= $rawData[0]['payload'];
|
||||||
$res1= $rawData; //['payload'];
|
// $res1= $rawData; //['payload'];
|
||||||
|
//
|
||||||
|
// // var_dump($res1);
|
||||||
|
//
|
||||||
|
// return $this->response->setJson($res1);
|
||||||
|
// $cache = \Config\Services::cache();
|
||||||
|
|
||||||
// var_dump($res1);
|
// $foo = $cache->get('foo');
|
||||||
|
|
||||||
return $this->response->setJson($res1);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<VirtualHost *:80>
|
<VirtualHost *:80>
|
||||||
ServerAdmin works@chiefsoft.com
|
ServerAdmin works@chiefsoft.com
|
||||||
ServerName blogdata.mermsemr.com
|
ServerName gate.float.sg
|
||||||
DocumentRoot /var/www/html/public
|
DocumentRoot /var/www/html/public
|
||||||
|
|
||||||
PassEnv CI_ENVIRONMENT
|
PassEnv CI_ENVIRONMENT
|
||||||
|
|||||||
Reference in New Issue
Block a user