Redis updates

This commit is contained in:
DESKTOP-GBA0BK8\Admin
2023-04-09 13:36:51 -04:00
parent b66a233d6b
commit a4a0345055
4 changed files with 58 additions and 18 deletions
+12 -5
View File
@@ -22,7 +22,7 @@ class Cache extends BaseConfig
*
* @var string
*/
public $handler = 'file';
public $handler = 'redis'; //'file';
/**
* --------------------------------------------------------------------------
@@ -35,7 +35,7 @@ class Cache extends BaseConfig
*
* @var string
*/
public $backupHandler = 'dummy';
public $backupHandler = 'file';
/**
* --------------------------------------------------------------------------
@@ -152,14 +152,21 @@ class Cache extends BaseConfig
*
* @var array<string, int|string|null>
*/
public $redis = [
'host' => '127.0.0.1',
'password' => null,
public $redis2 = [
'host' => '10.0.0.112',
'password' => 'adae59706edf22f9f61180578cd16cc2038703c7230ae012e3c783ace1d09d64',
'port' => 6379,
'timeout' => 0,
'database' => 0,
];
public $redis = [
'host' => '10.0.0.32',
'password' => '7f079034e166ecf52d82cbec9876e4dc8a154b0c37248f3fa1734d4eeab938d5',
'port' => 6378,
'timeout' => 0,
'database' => 0,
];
/**
* --------------------------------------------------------------------------
* Available Cache Handlers
+1 -1
View File
@@ -35,7 +35,7 @@ $routes->setAutoRoute(true);
$routes->get('/', 'Home::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
+44 -11
View File
@@ -5,12 +5,15 @@ namespace App\Controllers;
use CodeIgniter\API\ResponseTrait;
use CodeIgniter\Cache\CacheInterface;
class FloatWeb extends BaseController
{
use ResponseTrait;
protected $db;
public $con_name = 'float_blog';
private function apiData() {
$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()
{
$rawData = $this->apiData();
$res1= $rawData[0]['payload'];
// var_dump($res1);
return $this->response->setJson($res1);
// $res1= $rawData[0]['payload'];
$res1= $rawData; //[0]['payload'];
$this->runCache('blogdata',$res1['payload']);
$resJson = $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()
{
$rawData = $this->apiData();
// $res1= $rawData[0]['payload'];
$res1= $rawData; //['payload'];
// $rawData = $this->apiData();
// // $res1= $rawData[0]['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 -1
View File
@@ -1,6 +1,6 @@
<VirtualHost *:80>
ServerAdmin works@chiefsoft.com
ServerName blogdata.mermsemr.com
ServerName gate.float.sg
DocumentRoot /var/www/html/public
PassEnv CI_ENVIRONMENT