private void DifferentPrefix()
 {
     UseConnection(redis =>
     {
         var SecondStorage = new RedisStorage(Redis.ServerInfo, new RedisStorageOptions {
             Db = Redis.Storage.Db, Prefix = "test:"
         });
         var SecondConnection = SecondStorage.GetDatabase();
         Commit(redis, x => x.InsertToList("some-list", "value"));
         var transaction = new RedisWriteOnlyTransaction(SecondConnection.CreateTransaction(), SecondStorage.GetSubscribe(), SecondStorage.Prefix);
         transaction.InsertToList("some-list", "value2");
         transaction.Commit();
         Assert.Equal(1, redis.ListLength(Prefix + "some-list"));
         Assert.Equal(1, SecondConnection.ListLength(SecondStorage.Prefix + "some-list"));
         Assert.Equal("value", redis.ListLeftPop(Prefix + "some-list"));
         Assert.Equal("value2", SecondConnection.ListLeftPop(SecondStorage.Prefix + "some-list"));
     });
 }
Ejemplo n.º 2
0
        public RedisFixture()
        {
            var rnd = new Random();

            Port = (rnd.Next(10000) + 6379).ToString();

            string assemblyFile = new DirectoryInfo(new Uri(Assembly.GetExecutingAssembly().CodeBase).AbsolutePath).Parent.FullName;

            RedisServer = new Process();
            RedisServer.StartInfo.FileName        = assemblyFile + "//redis-server.exe";
            RedisServer.StartInfo.Arguments       = "--maxheap 8000000 --port " + Port;
            RedisServer.StartInfo.UseShellExecute = false;
            RedisServer.Start();

            var Server = String.Format("{0}:{1}", IP, Port);

            Storage = new RedisStorage(Server + ",allowAdmin=true", new RedisStorageOptions {
                Db = Db
            });
            CleanRedisAttribute.Server = Storage.GetDatabase().Multiplexer.GetServer(Server); //Ugly
            CleanRedisAttribute.Db     = Db;
        }
 private void DifferentPrefix()
 {
     UseConnection(redis =>
     {
         var SecondStorage = new RedisStorage(Redis.ServerInfo, new RedisStorageOptions { Db = Redis.Storage.Db, Prefix = "test:" });
         var SecondConnection = SecondStorage.GetDatabase();
         Commit(redis, x => x.InsertToList("some-list", "value"));
         var transaction = new RedisWriteOnlyTransaction(SecondConnection.CreateTransaction(), SecondStorage.GetSubscribe(), SecondStorage.Prefix);
         transaction.InsertToList("some-list", "value2");
         transaction.Commit();
         Assert.Equal(1, redis.ListLength(Prefix + "some-list"));
         Assert.Equal(1, SecondConnection.ListLength(SecondStorage.Prefix + "some-list"));
         Assert.Equal("value", redis.ListLeftPop(Prefix + "some-list"));
         Assert.Equal("value2", SecondConnection.ListLeftPop(SecondStorage.Prefix + "some-list"));
     });
 }