forked from alexdemers/csharp-resque
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStat.cs
47 lines (42 loc) · 1.23 KB
/
Stat.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using System;
namespace Resque
{
public class Stat
{
public static int Get(String stat)
{
using (var redis = Resque.PooledRedisClientManager.GetClient())
{
return Int32.Parse(redis.GetValue("resque:stat:" + stat));
}
}
public static void Increment(String stat, int amt)
{
using (var redis = Resque.PooledRedisClientManager.GetClient())
{
redis.IncrementValueBy("resque:stat:" + stat, amt);
}
}
public static void Increment(String stat)
{
using (var redis = Resque.PooledRedisClientManager.GetClient())
{
redis.Increment("resque:stat:" + stat, 1);
}
}
public static void Decrement(String stat)
{
using (var redis = Resque.PooledRedisClientManager.GetClient())
{
redis.Decrement("resque:stat:" + stat, 1);
}
}
public static void Clear(String stat)
{
using (var redis = Resque.PooledRedisClientManager.GetClient())
{
redis.Remove("resque:stat:" + stat);
}
}
}
}