本文整理汇总了C#中ServiceStack.Redis.PooledRedisClientManager类的典型用法代码示例。如果您正苦于以下问题:C# PooledRedisClientManager类的具体用法?C# PooledRedisClientManager怎么用?C# PooledRedisClientManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PooledRedisClientManager类属于ServiceStack.Redis命名空间,在下文中一共展示了PooledRedisClientManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateNewId
public long GenerateNewId()
{
using (var client = new PooledRedisClientManager(_redisHost).GetClient())
{
return client.As<long>().GetNextSequence();
}
}
示例2: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
var pooledClientManager = new PooledRedisClientManager("localhost");
var client = pooledClientManager.GetClient();
var blogRedis = new BlogRedis(client);
var memberRedis = new MemberRedis(client);
var Id = Request["ID"];
var idNull = string.IsNullOrEmpty(Id);
Item = new Member();
using (var con = DAL.con())
{
if (!idNull)
{
var blog = blogRedis.GetById(Convert.ToInt64(Id));
Item = memberRedis.GetByUsername(blog.NguoiTao);
//blog.Anhs = AnhDal.SelectByPId(con, blog.RowId.ToString(), 20);
//blog.Profile = Item;
ViewForProfile.Xes = Item.GetXe(client);
ViewForProfile.Nhoms = Item.GetNhom(client);
ViewForProfile.Pager = BinhLuanDal.PagerByPRowId(con, "", true, blog.RowId.ToString(), 20);
ViewForProfile.Blog = blog;
ViewForProfile.Item = Item;
}
}
}
示例3: RedisClientPoolManager
static RedisClientPoolManager()
{
try
{
connectTimeout = ConfigUtils.GetSetting("Redis.ConnectTimeout", 1);
poolTimeOut = ConfigUtils.GetSetting("Redis.PoolTimeOut", 300);
var readWriteHosts = ConfigUtils.GetSetting("Redis.Host.ReadWrite").Split(',');
var readOnlyHosts = ConfigUtils.GetSetting("Redis.Host.ReadOnly").Split(',');
var password = ConfigUtils.GetConnectionString("Redis.RequirePass");
var dbIndex = ConfigUtils.GetSetting("Redis.Db", 0);
dbIndex = dbIndex < 0 ? 0 : dbIndex;
readWriteHosts = ConvertHost(readWriteHosts, password);
readOnlyHosts = ConvertHost(readOnlyHosts, password);
var config = new RedisClientManagerConfig()
{
//“写”链接池链接数
MaxWritePoolSize = ConfigUtils.GetSetting("Redis.WritePool.MaxSize", 200),
//“读”链接池链接数
MaxReadPoolSize = ConfigUtils.GetSetting("Redis.Read.MaxSize", 200),
AutoStart = true
};
prcm = new PooledRedisClientManager(readWriteHosts, readOnlyHosts, config, dbIndex, PoolSizeMultiplier, poolTimeOut);
}
catch (Exception ex)
{
TraceLog.WriteError("Init the redis pool manager error:{0}", ex);
}
}
示例4: Pump
private static void Pump()
{
var pool = new PooledRedisClientManager(new string[] {"127.0.0.1"});
pool.ConnectTimeout = 30000;
pool.SocketSendTimeout = 30000;
pool.SocketReceiveTimeout = 30000;
var today = DateTime.Today;
for (var d = 0; d < _forwardDays; d++)
{
var ds = today.AddDays(d).ToString("yyyy-MM-dd");
for (var r = 1; r <= _numberOfRids; r++)
{
for (var ps = 1; ps <= _partySizeCacheMax; ps++)
{
var key = string.Format("AS1_{0}_{1}_{2}", r, ds, ps);
var val = string.Format("{0}_0_abcdefgh0123456789012345678901234567890123456789", r);
try
{
using (IRedisClient client = pool.GetClient())
{
client.Set(key, val);
}
}
catch (Exception)
{
}
}
}
}
}
示例5: Main
static void Main(string[] args)
{
ServiceStackHelper.Help();
using (var redisManager = new PooledRedisClientManager())
using (var redis = redisManager.GetClient())
{
var redisTodos = redis.As<Todo>();
for (int i = 0; i < 20000; i++)
{
var todo = new Todo
{
Id = redisTodos.GetNextSequence(),
Content = "Learn Redis",
Order = 1,
};
redisTodos.Store(todo);
Todo savedTodo = redisTodos.GetById(todo.Id);
savedTodo.Done = true;
redisTodos.Store(savedTodo);
//"Updated Todo:".Print();
//redisTodos.GetAll().ToList().PrintDump();
redisTodos.DeleteById(savedTodo.Id);
}
"No more Todos:".Print();
redisTodos.GetAll().ToList().PrintDump();
}
Console.ReadLine();
}
示例6: SaveMeals
public static bool SaveMeals(IList<Meal> meals)
{
using (var redisManager = new PooledRedisClientManager("[email protected]:9038"))
{
using (var client = redisManager.GetCacheClient())
{
IList<bool> result = new List<bool>();
//save meals by date...add to workout dates
foreach (Meal meal in meals)
{
Meal tempMeal = client.Get<Meal>(String.Format(saveMeals, meal.MealDate));
if (tempMeal != null && tempMeal.Foods != null)
{
foreach (var food in meal.Foods)
tempMeal.Foods.Add(food);
result.Add(client.Set<Meal>(String.Format(saveMeals, meal.MealDate), tempMeal));
}
else
{
result.Add(client.Add<Meal>(String.Format(saveMeals, meal.MealDate), meal));
WorkoutClient.AddWorkoutDate(meal.MealDate.Date);
}
}
return !result.Contains(false);
}
}
}
示例7: DeleteDataBulk
public Task<bool> DeleteDataBulk(IEnumerable<dynamic> Ids, string CollectionName)
{
try
{
using (var redisManager = new PooledRedisClientManager())
using (var redis = redisManager.GetClient())
{
foreach (var Fid in Ids)
{
var datas = redis.ScanAllKeys($"{DBName}:{CollectionName}:{Fid}");
foreach (var item in datas)
{
redis.Remove(item);
}
}
return Task.FromResult(true);
}
}
catch
{
//print ke log
//throw;
return Task.FromResult(false); ;
}
}
示例8: Configure
public override void Configure(Funq.Container container)
{
PathProvider.BinaryPath = "~".MapAbsolutePath();
ServiceStack.Text.JsConfig.EmitCamelCaseNames = true;
RequestBinders.Add(typeof(CommitAttempt), request => new CommitAttempt()
{
UserAgent = request.Headers["User-Agent"],
RawBody = request.GetRawBody()
});
Routes
.Add<CommitAttempt>("/commit")
.Add<CommitMessages>("/commits")
.Add<MessageErrors>("/errors")
// //.Add<CommitMessage>("/commitMessage")
;
var redisFactory = new PooledRedisClientManager("localhost:6379");
container.Register<IRedisClientsManager>(redisFactory);
//var mqHost = new RedisMqHost(redisFactory);
var mqHost = new RedisMqServer(redisFactory);
container.Register<IMessageService>(mqHost);
container.Register(mqHost.MessageFactory);
mqHost.RegisterHandler<CommitAttempt>(ServiceController.ExecuteMessage);
//mqHost.RegisterHandler<CommitMessage>(ServiceController.ExecuteMessage);
mqHost.Start();
}
示例9: Configure
public override void Configure(Container container)
{
string sc = ConfigurationManager.AppSettings.Get("DbConnection");
string rchost= ConfigurationManager.AppSettings.Get("SessionRedisHost");
rchost= (string.IsNullOrEmpty(rchost))? "localhost:6379": rchost;
string rcpassword= ConfigurationManager.AppSettings.Get("SessionRedisPassword");
string rcdbs= ConfigurationManager.AppSettings.Get("SessionRedisDb");
int rcdb;
if(! int.TryParse(rcdbs, out rcdb) ) rcdb= 10;
string sstout = ConfigurationManager.AppSettings.Get("SessionTimeout");
int sessionTimeout;
if(! int.TryParse(sstout, out sessionTimeout) ) sessionTimeout= 60*8;
var cacheClient= new BasicRedisClientManager( new string[]{rchost}, new string[]{rchost}, rcdb);
cacheClient.GetClient().Password= rcpassword;
container.Register<IAuthProvider>( new BdAuthProvider()
{
DbFactory=new ConnectionFactory(sc, FirebirdDialectProvider.Instance),
AuthUserSession= new UserSession()
{
CacheClient= cacheClient,
TimeOut=sessionTimeout,
}
});
string phost= ConfigurationManager.AppSettings.Get("CacheHost");
phost = (string.IsNullOrEmpty(phost))?"localhost:6379":phost;
string pdbs= ConfigurationManager.AppSettings.Get("CacheDb");
int pdb ;
if(! int.TryParse(pdbs, out pdb) ) pdb= 9;
string ppassword= ConfigurationManager.AppSettings.Get("CachePassword");
var p = new PooledRedisClientManager(new string[]{phost}, new string[]{phost}, pdb);
p.GetClient().Password= ppassword;
container.Register<ICacheClient>( p);
container.Register<IDbConnectionFactory>(
new ConnectionFactory(sc, FirebirdDialectProvider.Instance)
);
//Permit modern browsers (e.g. Firefox) to allow sending of any REST HTTP Method
base.SetConfig(new EndpointHostConfig
{
GlobalResponseHeaders =
{
{ "Access-Control-Allow-Origin", "*" },
{ "Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS" },
{ "Access-Control-Allow-Headers","X-Requested-With"}
},
});
log.InfoFormat("AppHost Configured: " + DateTime.Now);
}
示例10: ReadUser
public User ReadUser(int userId)
{
using (var pooledRedisClient = new PooledRedisClientManager())
using (var redis = pooledRedisClient.GetClient())
{
return redis.GetById<User>(userId);
}
}
示例11: ListArticles
public static List<Article> ListArticles()
{
using (var pooledRedisClient = new PooledRedisClientManager())
using (var redis = pooledRedisClient.GetClient())
{
return redis.Sets["Articles"].Select(x => redis.GetById<Article>(int.Parse(x))).ToList<Article>();
}
}
示例12: RedisConnection
//Método requerido para establecer una conexión con el servicio de Redis
private static void RedisConnection()
{
if (redisClient == null)
{
var clientsManager = new PooledRedisClientManager(RedisUri);
redisClient = clientsManager.GetClient();
}
}
示例13: BuildRedisPoolClient
/// <summary>
/// 建立连接池
/// </summary>
public void BuildRedisPoolClient()
{
RedisClientManagerConfig RedisConfig = new RedisClientManagerConfig();
RedisConfig.AutoStart = true;
RedisConfig.MaxReadPoolSize = RedisServicePoolSize;
RedisConfig.MaxWritePoolSize = RedisServicePoolSize;
PooledRedisClient = new PooledRedisClientManager(RedisServiceAddress, RedisServiceAddress, RedisConfig);
}
示例14: ReadArticle
public Article ReadArticle(int id)
{
using (var pooledRedisClient = new PooledRedisClientManager())
using (var redis = pooledRedisClient.GetClient())
{
return redis.GetById<Article>(id);
}
}
示例15: ReadComment
public Comment ReadComment(int commentId)
{
using (var pooledRedisClient = new PooledRedisClientManager())
using (var redis = pooledRedisClient.GetClient())
{
Comment target = redis.GetById<Comment>(commentId);
return target;
}
}