本文整理汇总了C#中ServiceStack.Redis.RedisClient.FlushAll方法的典型用法代码示例。如果您正苦于以下问题:C# RedisClient.FlushAll方法的具体用法?C# RedisClient.FlushAll怎么用?C# RedisClient.FlushAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ServiceStack.Redis.RedisClient
的用法示例。
在下文中一共展示了RedisClient.FlushAll方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateServer
RedisMqServer CreateServer()
{
using (var redis = new RedisClient(TestConfig.SingleHost))
redis.FlushAll();
var mqServer = new RedisMqServer(TestConfig.BasicClientManger);
mqServer.RegisterHandler<Spin0>(m => new Spin0 { Id = Interlocked.Increment(ref counter.Spin0) });
mqServer.RegisterHandler<Spin10>(m => {
var sw = Stopwatch.StartNew();
SpinWait.SpinUntil(() => sw.ElapsedMilliseconds < 10);
return new Spin10 { Id = Interlocked.Increment(ref counter.Spin10) };
});
mqServer.RegisterHandler<Spin100>(m => {
var sw = Stopwatch.StartNew();
SpinWait.SpinUntil(() => sw.ElapsedMilliseconds < 100);
return new Spin100 { Id = Interlocked.Increment(ref counter.Spin100) };
});
mqServer.RegisterHandler<Spin1000>(m => {
var sw = Stopwatch.StartNew();
SpinWait.SpinUntil(() => sw.ElapsedMilliseconds < 1000);
return new Spin1000 { Id = Interlocked.Increment(ref counter.Spin1000) };
});
return mqServer;
}
示例2: CreateServer
RedisMqServer CreateServer()
{
using (var redis = new RedisClient(TestConfig.SingleHost))
redis.FlushAll();
var mqServer = new RedisMqServer(TestConfig.BasicClientManger);
mqServer.RegisterHandler<Spin0>(m => new Spin0 { Id = counter.Spin0++ });
mqServer.RegisterHandler<Spin10>(m => {
var sw = Stopwatch.StartNew();
while (sw.ElapsedMilliseconds < 10) Thread.SpinWait(100000);
return new Spin10 { Id = counter.Spin10++ };
});
mqServer.RegisterHandler<Spin100>(m => {
var sw = Stopwatch.StartNew();
while (sw.ElapsedMilliseconds < 100) Thread.SpinWait(100000);
return new Spin100 { Id = counter.Spin100++ };
});
mqServer.RegisterHandler<Spin1000>(m => {
var sw = Stopwatch.StartNew();
while (sw.ElapsedMilliseconds < 1000) Thread.SpinWait(100000);
return new Spin1000 { Id = counter.Spin1000++ };
});
return mqServer;
}
示例3: ClearAll
public static void ClearAll()
{
using (var client = new RedisClient(CacheIp))
{
client.FlushDb();
client.FlushAll();
}
}
示例4: Init
public static void Init()
{
var uri = new Uri(ConfigurationManager.AppSettings["REDISTOGO_URL"]);
using (var redis = new RedisClient(uri))
{
redis.FlushAll();
var assignmentsStore = redis.As<Assignment>();
var assignments = new List<Assignment> {
new Assignment {Id = 1, CourseId = 1, Title = "Ch 1, 1-29 Odd", DueDate = new DateTime(2012, 12, 27)},
new Assignment {Id = 2, CourseId = 2, Title = "Ch 2, 1-21", DueDate = new DateTime(2012, 12, 28)},
new Assignment {Id = 3, CourseId = 2, Title = "Ch 2, 25-28, 29-27 Odd", DueDate = new DateTime(2013, 1, 5)},
new Assignment {Id = 4, CourseId = 4, Title = "Ch 3, 33-39, 41", DueDate = new DateTime(2012, 12, 20)}
};
assignmentsStore.StoreAll(assignments);
var coursesStore = redis.As<Course>();
var courses = new List<Course> {
new Course {Id = 1, Period = 1, TeacherId = 1, Subject = "Math", AssignmentIds = new int[] {1}, StudentIds = new int[] {1, 2}},
new Course {Id = 2, Period = 2, TeacherId = 1, Subject = "Advanced Math", AssignmentIds = new int[] {2, 3}},
new Course {Id = 3, Period = 3, TeacherId = 1, Subject = "Math"},
new Course {Id = 4, Period = 4, TeacherId = 1, Subject = "Science", AssignmentIds = new int[] {4}, StudentIds = new int[] {1}},
new Course {Id = 5, Period = 5, TeacherId = 1, Subject = "Science", StudentIds = new int[] {2}},
new Course {Id = 6, Period = 6, TeacherId = 1, Subject = "Math"},
new Course {Id = 7, Period = 1, TeacherId = 2, Subject = "History"}
};
coursesStore.StoreAll(courses);
var teachersStore = redis.As<Teacher>();
var teacher = new Teacher { Id = 1, Name = "Jane Doe", CourseIds = new int[] { 1, 2, 3, 4, 5, 6 } };
teachersStore.Store(teacher);
var studentsStore = redis.As<Student>();
var students = new List<Student> {
new Student {Id = 1, FirstName = "Bill", LastName = "Clinton", Grade = 8, CourseIds = new int[] {1, 4}},
new Student {Id = 2, FirstName = "George", LastName = "Bush", Grade = 8, CourseIds = new int[] {1, 5}},
new Student {Id = 3, FirstName = "Abraham", LastName = "Lincoln", Grade = 8, CourseIds = new int[0]},
new Student {Id = 4, FirstName = "George", LastName = "Washington", Grade = 8, CourseIds = new int[0]},
new Student {Id = 5, FirstName = "John", LastName = "Adams", Grade = 8, CourseIds = new int[0]},
new Student {Id = 6, FirstName = "Barack", LastName = "Obama", Grade = 8, CourseIds = new int[0]}
};
studentsStore.StoreAll(students);
}
}
示例5: CreateServer
RedisMqServer CreateServer()
{
using (var redis = new RedisClient(TestConfig.SingleHost))
redis.FlushAll();
var mqServer = new RedisMqServer(TestConfig.BasicClientManger);
mqServer.RegisterHandler<Sleep0>(m => new Sleep0 { Id = counter.Sleep0++ });
mqServer.RegisterHandler<Sleep10>(m => {
Thread.Sleep(10);
return new Sleep10 { Id = counter.Sleep10++ };
});
mqServer.RegisterHandler<Sleep100>(m => {
Thread.Sleep(100);
return new Sleep100 { Id = counter.Sleep100++ };
});
mqServer.RegisterHandler<Sleep1000>(m => {
Thread.Sleep(1000);
return new Sleep1000 { Id = counter.Sleep1000++ };
});
return mqServer;
}
示例6: AppHost
public AppHost()
: base("Furnace.Boiler.Play", typeof(AppHost).Assembly)
{
var contentTypes = new RoslynContentTypes(
@"C:\GitHub\Furnace\Src\Furnace.Boiler.Models.Play\Furnace.Boiler.Models.Play.csproj",
@"C:\GitHub\Furnace\Src\Furnace.Boiler\bin\FurnaceObjectTypes\FurnaceObjectType.cs");
contentTypes.GetContentTypes();
contentTypes.CompileFurnaceContentTypes();
var siteConfig = new FurnaceSiteConfiguration(new CultureInfo("en-AU"));
var redisClient = new RedisClient("localhost");
redisClient.FlushAll();
Items = new RedisBackedFurnaceItems(redisClient, siteConfig, contentTypes);
var pageType = contentTypes.GetContentTypes().Single(x => x.FullName == typeof(Page).FullName);
for (var i = 2L; i < 100; i++)
{
var p = Items.CreateItem(pageType);
p.Propities.Add("Title", "Page " + i);
p.Propities.Add("Body", "Body " + i);
p.FurnaceItemInformation = new FurnaceItemInformation<long>
{
ParentId = 1L,
ParentContentTypeFullName = typeof (Page).FullName,
ContentTypeFullName = typeof (Page).FullName,
Id = i
};
p.Save(redisClient);
}
}
示例7: Main
/*
/// <summary>
/// http://geekswithblogs.net/shaunxu/archive/2012/04/27/redis-on-windows.aspx
/// </summary>
/// <param name="args"></param>
static void Main(string[] args)
{
using (var redis = new RedisClient(RedisConStr))
{
redis.FlushAll();
}
//Dequeue();
//Enqueue();
}
*/
static void Main(string[] args)
{
using (var redis = new RedisClient(RedisConStr))
{
redis.FlushAll();
}
var consumerThread1 = new Thread(new ParameterizedThreadStart(ConsumerAction));
var consumerThread2 = new Thread(new ParameterizedThreadStart(ConsumerAction));
var consumerThread3 = new Thread(new ParameterizedThreadStart(ConsumerAction));
consumerThread1.Start("Consumer 1");
consumerThread2.Start("Consumer 2");
consumerThread3.Start("Consumer 3");
using (var publisher = new RedisClient(RedisConStr))
{
Console.WriteLine("Input message: ");
var message = Console.ReadLine();
while (!string.IsNullOrWhiteSpace(message))
{
publisher.PublishMessage("default", message);
Console.WriteLine("Input message: ");
message = Console.ReadLine();
}
}
Console.WriteLine("Done!");
Console.ReadKey();
}
示例8: Main
static void Main()
{
using (var store = new DocumentStore {
Url = "http://localhost:8080"
}.Initialize())
{
if (store.DatabaseCommands.GetIndex("Users/ByName") != null)
store.DatabaseCommands.DeleteIndex("Users/ByName");
store.DatabaseCommands.PutIndex("Users/ByName",
new IndexDefinition {
Map = "from doc in docs.Users select new { doc.Name } "
});
WriteAllWithRaven(store);
using (var redisClient = new RedisClient("localhost"))
{
redisClient.FlushAll();
WriteAllWithRedis(redisClient);
}
WaitForNonStaleResult(store);
QueryByFullName(store);
QueryByPartialName(store);
}
}
示例9: Main
public static void Main()
{
try
{
var path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
var file = Path.Combine(Path.Combine(path, "cmd"), "redis-server.exe");
if (File.Exists(file))
{
var redis = new ProcessStartInfo()
{
FileName = file
};
using (var server = Process.Start(redis))
{
if (server.Responding)
{
using (var client = new RedisClient())
{
client.FlushAll();
CatalogInitializer.Configure();
// Create
"[CREATE] StoreAll".ToConsoleInfo();
client.StoreAll<Book>(CatalogInitializer.Seed());
// Read
"[READ] GetAll".ToConsoleInfo();
var catalog = client.GetAll<Book>().ToList();
catalog.ForEach(retrieved => retrieved.ToJson<Book>().ToConsole());
var isbn = "9780596800956";
string.Format("[READ] GetById (Isbn = {0})", isbn).ToConsoleInfo();
client.GetById<Book>(isbn).ToJson<Book>().ToConsole();
// Update
"[UPDATE] (InStock = false)".ToConsoleInfo();
var book = client.GetById<Book>(isbn);
book.InStock = false;
client.Store<Book>(book);
client.GetById<Book>(isbn).ToJson<Book>().ToConsole();
// Delete
string.Format("[DELETE] DeleteById (Isbn = {0})", isbn).ToConsoleInfo();
client.DeleteById<Book>(isbn);
client.GetById<Book>(isbn).ToJson<Book>().ToConsole();
}
}
}
}
}
catch (Exception exception)
{
exception.ToString().ToConsole();
}
finally
{
"Press any key to continue . . .".ToConsole();
Console.ReadKey(true);
}
}
示例10: Before
public void Before()
{
client = new RedisClient("localhost");
client.FlushAll();
}
示例11: Main
private static void Main(string[] args)
{
string host = "10.2.9.104";
string elementKey = "testKeyRedis";
string message = "";
using (RedisClient redisClient = new RedisClient(host, 6379))
{
redisClient.FlushAll();
redisClient.Set("test", "test12345");
byte[] s = redisClient.Get("test");
}
}
示例12: Post
public void Post()
{
var client = new RedisClient();
client.FlushAll();
}
示例13: Handle
/// <summary>
/// Handles the specified request.
/// </summary>
/// <param name="request">The request.</param>
public void Handle(DeployRequestDto request)
{
var client = new RedisClient();
client.FlushAll();
}
示例14: Main
static void Main(string[] args)
{
//Can't load 900000-600000 from 1 key -> buffer to small
//Can't save 1300000 to 1 key -> ?
//50 mb
//Took 3531.25ms to store (300000 records in 1 key)
//Took 2953.125ms to load (300000 records from 1 key)
//Removed all keys from db
//Took 17765.625ms to store (300000 records in list)
//Took 3140.625ms to load (300000 records from list)
///************************************
//Took 5265.625ms to store (500000 records in 1 key)
//Took 4921.875ms to load (500000 records from 1 key)
//Removed all keys from db
//Took 29531.25ms to store (500000 records in list)
//Took 5359.375ms to load (500000 records from list)
//noute
//Took 4243,2427ms to store (300000 records in 1 key)
//Took 4480,2562ms to load (300000 records from 1 key)
//Took 4448,2544ms to load (1 item from 1 key): test Description _Description_0
//Removed all keys from db
//Took 30159,725ms to store (300000 records in list)
//Took 4279,2447ms to load (300000 records from list)
//Took 22,0013ms to load (1 item from 1 key): test Description _Description_100
//Removed all keys from db
//************************
//Testing Raven DB...
//Took 14101,8066ms to store (30000 records in 1 key)
//Took 10028,5736ms to load (30000 records from 1 key)
//tst redis
int totalRecords = 300000;
//int totalRecords = 30000;
var trans = new List<Transaction>();
for (int i = 0; i < totalRecords; i++)
{
trans.Add(new Transaction() { Description = "test Description _Description_" + i, Id = i });
}
var before = DateTime.Now;
//TimeSpan exp = new TimeSpan(0, 2400, 0);
using (var redisClient = new RedisClient())
{
var typedRedis = redisClient.GetTypedClient<List<Transaction>>();
typedRedis.SetEntry("test", trans);
}
Console.WriteLine("Took {0}ms to store ({1} records in 1 key)", (DateTime.Now - before).TotalMilliseconds, totalRecords);
before = DateTime.Now;
using (var redisClient = new RedisClient())
{
var typedRedis = redisClient.GetTypedClient<List<Transaction>>();
trans = typedRedis["test"];
}
Console.WriteLine("Took {0}ms to load ({1} records from 1 key)", (DateTime.Now - before).TotalMilliseconds, trans.Count);
before = DateTime.Now;
using (var redisClient = new RedisClient())
{
var typedRedis = redisClient.GetTypedClient<List<Transaction>>();
trans = typedRedis["test"];
}
Console.WriteLine("Took {0}ms to load (1 item from 1 key): {1}", (DateTime.Now - before).TotalMilliseconds, trans[0].Description);
using (var redisClient = new RedisClient())
{
redisClient.FlushAll();
}
Console.WriteLine("Removed all keys from db");
using (var redisClient = new RedisClient())
{
var typedRedis = redisClient.GetTypedClient<Transaction>();
var currStat = typedRedis.Lists["test"];
//trans.ForEach(x => currStat.Add(x));
currStat.AddRange(trans);
}
Console.WriteLine("Took {0}ms to store ({1} records in list)", (DateTime.Now - before).TotalMilliseconds, totalRecords);
before = DateTime.Now;
using (var redisClient = new RedisClient())
{
var typedRedis = redisClient.GetTypedClient<Transaction>();
var currStat = typedRedis.Lists["test"];
trans = currStat.GetAll();
}
Console.WriteLine("Took {0}ms to load ({1} records from list)", (DateTime.Now - before).TotalMilliseconds, trans.Count);
before = DateTime.Now;
using (var redisClient = new RedisClient())
{
var typedRedis = redisClient.GetTypedClient<Transaction>();
var currStat = typedRedis.Lists["test"];
var tr = new Transaction() { Id = 100 };
var res = currStat[currStat.IndexOf(tr)];
Console.WriteLine("Took {0}ms to load (1 item from 1 key): {1}", (DateTime.Now - before).TotalMilliseconds, res.Description);
//.........这里部分代码省略.........