本文整理汇总了C#中IRedisClient类的典型用法代码示例。如果您正苦于以下问题:C# IRedisClient类的具体用法?C# IRedisClient怎么用?C# IRedisClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IRedisClient类属于命名空间,在下文中一共展示了IRedisClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TrackInstance
private IRedisClient TrackInstance(MethodBase callingMethodType, string method, IRedisClient instance)
{
// track
var frame = new TrackingFrame()
{
Id = Guid.NewGuid(),
Initialised = DateTime.Now,
ProvidedToInstanceOfType = callingMethodType.DeclaringType,
};
lock (this.trackingFrames)
{
this.trackingFrames.Add(frame);
}
// proxy
var proxy = new TrackingRedisClientProxy(instance, frame.Id);
proxy.BeforeInvoke += (sender, args) =>
{
if (string.Compare("Dispose", args.MethodInfo.Name, StringComparison.InvariantCultureIgnoreCase) != 0)
{
return;
}
lock (this.trackingFrames)
{
this.trackingFrames.Remove(frame);
}
var duration = DateTime.Now - frame.Initialised;
Logger.DebugFormat("{0,18} Disposed {1} released from instance of type {2} checked out for {3}", method, frame.Id, frame.ProvidedToInstanceOfType.FullName, duration);
};
Logger.DebugFormat("{0,18} Tracking {1} allocated to instance of type {2}", method, frame.Id, frame.ProvidedToInstanceOfType.FullName);
return proxy.GetTransparentProxy() as IRedisClient;
}
示例2: SetKey
private void SetKey(IRedisClient client, int count)
{
for(int i = 1; i <= count; i++)
{
client.Set("key" + i, count);
}
}
示例3: DisposableDistributedLock
/// <summary>
/// Lock
/// </summary>
/// <param name="client"></param>
/// <param name="globalLockKey"></param>
/// <param name="acquisitionTimeout">in seconds</param>
/// <param name="lockTimeout">in seconds</param>
public DisposableDistributedLock(IRedisClient client, string globalLockKey, int acquisitionTimeout, int lockTimeout)
{
myLock = new DistributedLock();
myClient = client;
this.globalLockKey = globalLockKey;
lockState = myLock.Lock(globalLockKey, acquisitionTimeout, lockTimeout, out lockExpire, myClient);
}
示例4: FlushRedis
protected static void FlushRedis(IRedisClient redisClient)
{
foreach (var key in redisClient.SearchKeys("recommendify-test*"))
{
redisClient.Remove(key);
}
}
示例5: AssertClientHasHost
private static void AssertClientHasHost(IRedisClient client, string hostWithOptionalPort)
{
var parts = hostWithOptionalPort.Split(':');
var port = parts.Length > 1 ? int.Parse(parts[1]) : RedisNativeClient.DefaultPort;
Assert.That(client.Host, Is.EqualTo(parts[0]));
Assert.That(client.Port, Is.EqualTo(port));
}
示例6: GetClient
public IRedisClient<string> GetClient()
{
if (_client == null || _client.IsDisposed || _invalidated)
_client = new RedisClient(_host, _port);
_invalidated = false;
return _client;
}
示例7: RedisJobFetcher
public RedisJobFetcher(
IRedisClient redis,
IEnumerable<string> queueNames,
TimeSpan fetchTimeout)
{
_redis = redis;
_queueNames = queueNames.ToList();
_fetchTimeout = fetchTimeout;
}
示例8: RedisTempDataProvider
public RedisTempDataProvider(RedisTempDataProviderOptions options, IRedisClient redis)
{
if (options == null) throw new ArgumentNullException("options");
if (redis == null) throw new ArgumentNullException("redis");
// Copy so that references can't be modified outside of thsi class.
this.options = new RedisTempDataProviderOptions(options);
this.redis = redis;
}
示例9: Base
public Base(int maxNeighbours, string redisPrefix, IRedisClient redisClient)
{
RedisClient = redisClient;
MaxNeighbours = maxNeighbours;
RedisPrefix = redisPrefix;
InputMatrices = new Dictionary<string, InputMatrix>();
SimilarityMatrix = new SimilarityMatrix(
new Options {Key = "similarities", MaxNeighbours = MaxNeighbours, RedisPrefix = RedisPrefix},
redisClient);
}
示例10: RedisResultCollection
public RedisResultCollection(IRedisClient client, string filePrefix)
{
this.client = client;
this.filePrefix = filePrefix;
this.testRunInfos = new RedisInfoCollection<TestRun>(client, () => new TestRun());
if(!Directory.Exists(filePrefix))
Directory.CreateDirectory(filePrefix);
ForceUnlock();
}
示例11: LoadBasicStrings
protected void LoadBasicStrings(IRedisClient redis)
{
int A = 'A';
int Z = 'Z';
var letters = (Z - A + 1).Times(i => ((char)(i + A)).ToString());
var numbers = new[] { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine" };
var pos = 0;
letters.Each(x => redis.Set("string:letters/" + x, x));
numbers.Each(x => redis.Set("string:numbers/" + pos++, x));
}
示例12: RedisBackedFurnaceItemsTestsSetUp
public void RedisBackedFurnaceItemsTestsSetUp()
{
Client = Substitute.For<IRedisClient>();
ContentTypes = Substitute.For<IFurnaceContentTypes>();
ContentType = new ContentType { Name = ContentTypeName, Namespace = ContentTypeNamespace };
SiteConfiguration = Substitute.For<IFurnaceSiteConfiguration>();
SiteConfiguration.DefaultSiteCulture.Returns(new CultureInfo("en-AU"));
Sut = new RedisBackedFurnaceItems(Client, SiteConfiguration, ContentTypes);
}
示例13: RedisFetchedJob
public RedisFetchedJob(IRedisClient redis, string jobId, string queue)
{
if (redis == null) throw new ArgumentNullException("redis");
if (jobId == null) throw new ArgumentNullException("jobId");
if (queue == null) throw new ArgumentNullException("queue");
_redis = redis;
JobId = jobId;
Queue = queue;
}
示例14: DAO
public DAO()
{
_client = new RedisClient();
//Set to 1 to avoid conflicts with any default installs
//TODO: make configurable
_client.Db = 1;
}
示例15: RedisRegistryProvider
public RedisRegistryProvider()
{
if (SeifApplication.AppEnv.GlobalConfiguration.RegistryConfiguration == null)
throw new Exception("注册中心配置有误");
string url = SeifApplication.AppEnv.GlobalConfiguration.RegistryConfiguration.Url;
string collectionName = "RegistryData";
var attrs = DictionaryUtils.GetFromConfig(SeifApplication.AppEnv.GlobalConfiguration.RegistryConfiguration.AddtionalFields);
if (attrs != null && attrs.ContainsKey(AttrKeys.Registry_RedisCollectionName) )
{
if (!string.IsNullOrEmpty(attrs[AttrKeys.Registry_RedisCollectionName]))
{
collectionName = attrs[AttrKeys.Registry_RedisCollectionName];
}
}
_redisClient = new RedisClient(url);
_typedClient = _redisClient.As<RegistryDataInfo>();
_table = _typedClient.Lists[collectionName];
_redisSubscription = _redisClient.CreateSubscription();
_redisSubscription.OnMessage += (channel, msg) =>
{
var data = _serializer.Deserialize<ServiceRegistryMetta>(msg);
if (this.ServiceChanged == null) return;
this.ServiceChanged(this, new ServiceNotifyEventArgs
{
Data = data
});
};
}