本文整理匯總了C#中ServiceStack.Redis.PooledRedisClientManager.GetClient方法的典型用法代碼示例。如果您正苦於以下問題:C# PooledRedisClientManager.GetClient方法的具體用法?C# PooledRedisClientManager.GetClient怎麽用?C# PooledRedisClientManager.GetClient使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ServiceStack.Redis.PooledRedisClientManager
的用法示例。
在下文中一共展示了PooledRedisClientManager.GetClient方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: 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();
}
示例2: 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)
{
}
}
}
}
}
示例3: 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); ;
}
}
示例4: 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;
}
}
}
示例5: 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);
}
示例6: 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();
}
}
示例7: 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>();
}
}
示例8: ReadArticle
public Article ReadArticle(int id)
{
using (var pooledRedisClient = new PooledRedisClientManager())
using (var redis = pooledRedisClient.GetClient())
{
return redis.GetById<Article>(id);
}
}
示例9: ReadUser
public User ReadUser(int userId)
{
using (var pooledRedisClient = new PooledRedisClientManager())
using (var redis = pooledRedisClient.GetClient())
{
return redis.GetById<User>(userId);
}
}
示例10: DeleteComment
public void DeleteComment(int commentId)
{
using (var pooledRedisClient = new PooledRedisClientManager())
using (var redis = pooledRedisClient.GetClient())
{
var redisComment = redis.As<Comment>();
redisComment.DeleteById(commentId); // Delete old user using ID
}
}
示例11: DeleteUser
public void DeleteUser(int userId)
{
using (var pooledRedisClient = new PooledRedisClientManager())
using (var redis = pooledRedisClient.GetClient())
{
var redisUser = redis.As<User>();
redisUser.DeleteById(userId); // Delete old user using ID
}
}
示例12: ReadUsername
// New methods using usernames instead of IDs
public static User ReadUsername(string username)
{
using (var pooledRedisClient = new PooledRedisClientManager())
using (var redis = pooledRedisClient.GetClient())
{
User target = redis.GetById<User>(redis.Get<int>(username + ":id"));
return target;
}
}
示例13: DeleteArticle
public void DeleteArticle(int id)
{
using (var pooledRedisClient = new PooledRedisClientManager())
using (var redis = pooledRedisClient.GetClient())
{
var redisArticle = redis.As<Article>();
redisArticle.DeleteById(id);
}
}
示例14: ReadComment
public Comment ReadComment(int commentId)
{
using (var pooledRedisClient = new PooledRedisClientManager())
using (var redis = pooledRedisClient.GetClient())
{
Comment target = redis.GetById<Comment>(commentId);
return target;
}
}
示例15: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
var pooledClientManager = new PooledRedisClientManager("localhost");
var client = pooledClientManager.GetClient();
var alias = Request["Alias"];
using (var con = DAL.con())
{
var objRedis = new ObjRedis(client);
var obj = objRedis.GetByAlias(alias);
if(obj != null && !string.IsNullOrEmpty(obj.Url))
{
Response.Redirect(obj.Url, true);
}
var memberRedis = new MemberRedis(client);
var promotedUsers = memberRedis.GetXacNhanItems(0, 7);
//UserHomeList.List = MemberDal.SelectPromoted(con, 8, 61);
UserHomeList.List = promotedUsers;
var blogRedis = new BlogRedis(client);
//var userBlogs = BlogDal.SelectTopBlogProfile(con, 10, Security.Username, null);
var userBlogs = blogRedis.GetNhatKyItems(0, 9);
blogTop.List = userBlogs;
//var carBlogs = BlogDal.SelectTopBlogXe(con, 10, Security.Username, null);
var carBlogs = blogRedis.GetHanhTrinhItems(0, 10);
nhatKyXeTop.List = carBlogs;
var xeRedis = new XeRedis(client);
//var topCars = XeDal.HomeTop;
var topCars = xeRedis.GetAllItems(0, 9);
//var newstpCars = XeDal.HomeNewest;
var newstpCars = xeRedis.GetTopItems(0, 9);
topCarsList.List = topCars;
newestCarsList.List = newstpCars;
promotedHome.Visible = false;
promotedHome.HomeBig = XeDal.PromotedHomeBig.FirstOrDefault();
promotedHome.HomeMedium = XeDal.PromotedHomeMedium.Take(2).ToList();
promotedHome.HomeSMall = XeDal.PromotedHomeSmall.Take(4).ToList();
var loaiDanhMucRedis = new LoaiDanhMucRedis(client);
var hangXe = loaiDanhMucRedis.GetByAlias("HANGXE");
//var hangXeList = DanhMucDal.SelectByLDMMa(con, "HANGXE");
if(hangXe!=null)
{
var hangXeList = hangXe.GetDanhMuc(client);
var hangList = (from p in hangXeList
where p.PID == Guid.Empty
select p).OrderBy(m => m.ThuTu).ToList();
LeftMenu.List = hangList;
}
}
}