Exemple #1
0
 /// <summary>
 /// 清除指定数据库的所有数据。
 /// </summary>
 /// <param name="index"></param>
 public void FlushDb(long index)
 {
     using (IRedisClient client = base.pooledRedisClientManager.GetClient())
     {
         client.Db = index;
         client.FlushDb();
     }
 }
        /// <summary>
        /// 清空所有缓存
        /// </summary>
        public static void RemoveAll(long dbId = 0)
        {
            var          clientManager = GetClientManager(dbId);
            IRedisClient redis         = clientManager.GetClient();

            redis.FlushDb();
            clientManager.DisposeClient((RedisNativeClient)redis);
            redis.Dispose();
            clientManager.Dispose();
        }
Exemple #3
0
        public static void BeforeRedisScenario()
        {
            GlobalLock.Acquire();
            LogManager.LogFactory = new ConsoleLogFactory();

            Storage = new RedisStorage(RedisHost, RedisDb);
            JobStorage.Current = Storage;

            Client = Storage.PooledManager.GetClient();
            Client.FlushDb();
        }
Exemple #4
0
        public static void FlushDatabase(string host, int port, string password)
        {
            RedisUtils redisUtils = new RedisUtils(host, port, password);

            using (IRedisClient client = redisUtils.GetClient())
            {
                Console.WriteLine($"Flushing Database");
                Common.DashLine();
                client.FlushDb();
                Console.WriteLine($"Finished");
            }
        }
Exemple #5
0
        public Server()
        {
            string redisAddr = API.GetConvar("trackm_redis_addr", "127.0.0.1:6379");

            SplitHostPort(redisAddr, out string redisHost, out int redisPort);

            int redisDb = API.GetConvarInt("trackm_redis_db", 0);

            var settings = RedisSettings.Build()
                           .Host(redisHost)
                           .Port(redisPort)
                           .ReconnectOnIdle(true)
                           .ReissueCommandsOnReconnect(false);

            pool = new ThreadwisePool(settings, redisDb);

            IRedisClient <string> client = pool.GetClient();

            client.FlushDb();

            updateInterval = API.GetConvarInt("trackm_update_interval", 1000);
            if (updateInterval < MinimumUpdateInterval)
            {
                Debug.WriteLine("trackm_update_interval set too low ({0}ms) using minimum {1}ms.", updateInterval, MinimumUpdateInterval);
                updateInterval = MinimumUpdateInterval;
            }

            movementThreshold = API.GetConvarInt("trackm_movement_threshold", 1);
            if (movementThreshold < MinimumMovementThreshold)
            {
                Debug.WriteLine("trackm_movement_threshold set too low ({0}m) using minimum {1}m.", movementThreshold, MinimumMovementThreshold);
                movementThreshold = MinimumMovementThreshold;
            }
            // clients deal with squared distances
            movementThreshold *= movementThreshold;

            // fivem events
            EventHandlers["playerDropped"] += new Action <Player, string>(PlayerDropped);

            // internal events
            EventHandlers[Prefix + "register"]   += new Action <Player, int, string, string>(Register);
            EventHandlers[Prefix + "unregister"] += new Action <Player, int>(Unregister);

            // public events
            EventHandlers[Prefix + "Track"]          += new Action <int, int>(Track);
            EventHandlers[Prefix + "Untrack"]        += new Action <int, int>(Untrack);
            EventHandlers[Prefix + "MetadataGet"]    += new Action <int, int, string, CallbackDelegate>(MetadataGet);
            EventHandlers[Prefix + "MetadataSet"]    += new Action <int, int, string, string>(MetadataSet);
            EventHandlers[Prefix + "MetadataDelete"] += new Action <int, int, string>(MetadataDelete);
        }
Exemple #6
0
 public void FlushDB()
 {
     _redisCli.FlushDb();
 }
 public void FlushDb(string webAppId)
 {
     using IRedisClient client = GetWebAppRedisClient(webAppId);
     client.FlushDb();
 }