Compare commits

1 Commits

Author SHA1 Message Date
cdeed1b70a Use redis to store ignore lists 2025-04-13 20:53:38 +07:00
3 changed files with 10 additions and 9 deletions

View File

@@ -39,6 +39,9 @@ $cookiename = 'SMFCookie10'; # Name of the cookie to set for authentication.
$memcached_host = 'memcached'; $memcached_host = 'memcached';
$memcached_port = 11211; $memcached_port = 11211;
$redis_host = 'valkey';
$redis_port = 6379;
$recaptcha_secret = '6LfbSRUUAAAAAM4goUyXz9gB21cfIHL0ZhiQ6doM'; $recaptcha_secret = '6LfbSRUUAAAAAM4goUyXz9gB21cfIHL0ZhiQ6doM';
$recaptcha_site_key = '6LfbSRUUAAAAAN1TtRVmVsHw8NKWe5w50fzjyK3U'; $recaptcha_site_key = '6LfbSRUUAAAAAN1TtRVmVsHw8NKWe5w50fzjyK3U';
########## Database Info ########## ########## Database Info ##########

View File

@@ -8,7 +8,7 @@ if (!defined('SMF'))
function ignore() function ignore()
{ {
global $topic, $txt, $db_prefix, $context, $scripturl, $sourcedir, $ID_MEMBER, $mongodb; global $topic, $txt, $db_prefix, $context, $scripturl, $sourcedir, $ID_MEMBER, $redis;
// We need at least a topic... go away if you don't have one. // We need at least a topic... go away if you don't have one.
if (empty($topic)) if (empty($topic))
@@ -19,17 +19,14 @@ function ignore()
$ignoree_id = $_GET['member']; $ignoree_id = $_GET['member'];
$msg = $_GET['msg']; $msg = $_GET['msg'];
if ($ID_MEMBER > 0 && $ignoree_id > 0) if ($ID_MEMBER > 0 && $ignoree_id > 0)
$mongodb->rock->ignorelists->update( $redis->sadd("ignore:${ID_MEMBER}", $ignoree_id);
array ('user' => (int) $ID_MEMBER),
array ('$addToSet' => array ('ignores' => $ignoree_id)),
array ('upsert' => true));
// Back to the topic! // Back to the topic!
redirectexit('topic=' . $topic . '.msg'.$msg."#msg".$msg); redirectexit('topic=' . $topic . '.msg'.$msg."#msg".$msg);
} }
function unignore() function unignore()
{ {
global $topic, $txt, $db_prefix, $context, $scripturl, $sourcedir, $ID_MEMBER, $mongodb; global $topic, $txt, $db_prefix, $context, $scripturl, $sourcedir, $ID_MEMBER, $redis;
// We need at least a topic... go away if you don't have one. // We need at least a topic... go away if you don't have one.
if (empty($topic)) if (empty($topic))
@@ -40,9 +37,7 @@ function unignore()
$ignoree_id = $_GET['member']; $ignoree_id = $_GET['member'];
$msg = $_GET['msg']; $msg = $_GET['msg'];
if ($ID_MEMBER > 0 && $ignoree_id > 0) if ($ID_MEMBER > 0 && $ignoree_id > 0)
$mongodb->rock->ignorelists->update( $redis->sadd("ignore:${ID_MEMBER}", $ignoree_id);
array ('user' => (int) $ID_MEMBER),
array ('$pull' => array ('ignores' => $ignoree_id)));
// Back to the topic! // Back to the topic!
redirectexit('topic=' . $topic . '.msg'.$msg."#msg".$msg); redirectexit('topic=' . $topic . '.msg'.$msg."#msg".$msg);

View File

@@ -78,6 +78,9 @@ if (!$db_connection || !@mysql_select_db($db_name, $db_connection))
$memcached = new Memcached(); $memcached = new Memcached();
$memcached->addServer($memcached_host, $memcached_port); $memcached->addServer($memcached_host, $memcached_port);
$redis = new Redis();
$redis->connect($redis_host, $redis_port);
// //
mysql_query("SET NAMES 'utf8'"); mysql_query("SET NAMES 'utf8'");
mysql_query("set SESSION sql_mode='STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'"); mysql_query("set SESSION sql_mode='STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'");