-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
-> Time to test redis
- Loading branch information
Showing
20 changed files
with
368 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
{ | ||
"cSpell.words": [ | ||
"Predis", | ||
"Swal", | ||
"sweetalert" | ||
] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
|
||
use MythicalClient\App; | ||
use MythicalClient\Chat\User; | ||
use MythicalClient\Mail\Mail; | ||
use MythicalSystems\CloudFlare\Turnstile; | ||
use MythicalClient\Config\ConfigInterface; | ||
use MythicalSystems\CloudFlare\CloudFlare; | ||
use MythicalClient\Chat\columns\UserColumns; | ||
|
||
$router->get('/api/user/auth/logout', function (): void { | ||
echo '<script> | ||
localStorage.clear(); | ||
sessionStorage.clear(); | ||
</script>'; | ||
try { | ||
setcookie('user_token', '', time() - 460800 * 460800 * 460800, '/'); | ||
if (session_status() === PHP_SESSION_ACTIVE) { | ||
session_unset(); | ||
session_destroy(); | ||
} | ||
|
||
header('location: /auth/login?href=api'); | ||
exit; | ||
} catch (Exception $e) { | ||
App::getInstance(true)->getLogger()->error('Failed to logout user' . $e->getMessage()); | ||
header('location: /auth/login?href=api'); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
namespace MythicalClient\FastChat; | ||
|
||
use MythicalClient\App; | ||
use Predis\Client; | ||
|
||
class Redis | ||
{ | ||
private $redis; | ||
public function __construct() | ||
{ | ||
$app = App::getInstance(true); | ||
$app->loadEnv(); | ||
$host = $_ENV['REDIS_HOST']; | ||
$pwd = $_ENV['REDIS_PASSWORD']; | ||
$client = new Client([ | ||
'scheme' => 'tcp', | ||
'host' => $host, | ||
]); | ||
$this->redis = $client; | ||
} | ||
|
||
public function getRedis(): Client | ||
{ | ||
return $this->redis; | ||
} | ||
|
||
public function testConnection(): bool | ||
{ | ||
try { | ||
$redis = $this->getRedis(); | ||
$redis->connect(); | ||
return $redis->isConnected(); | ||
} catch (\Exception $e) { | ||
App::getInstance(true)->getLogger()->error('Failed to connect to Redis: ' . $e->getMessage()); | ||
return false; | ||
} | ||
} | ||
} |
Oops, something went wrong.