예제 #1
0
 public RequestProcessor(OsmiumMineContext context)
 {
     Context = context;
 }
        public KeyValueDatabaseService(OsmiumMineContext context)
        {
            Context = context;

            var commandMap = CommandMap.Default;

            if (Context.Configuration.DatabaseType != OMDatabaseConfiguration.RedisDatabaseType.Redis)
            {
                switch (Context.Configuration.DatabaseType)
                {
                case OMDatabaseConfiguration.RedisDatabaseType.SSDB:
                    commandMap = CommandMap.Create(new HashSet <string>
                    {
                        // see http://www.ideawu.com/ssdb/docs/redis-to-ssdb.html
                        "ping",
                        "get",
                        "set",
                        "del",
                        "incr",
                        "incrby",
                        "mget",
                        "mset",
                        "keys",
                        "getset",
                        "setnx",
                        "hget",
                        "hset",
                        "hdel",
                        "hincrby",
                        "hkeys",
                        "hvals",
                        "hmget",
                        "hmset",
                        "hlen",
                        "zscore",
                        "zadd",
                        "zrem",
                        "zrange",
                        "zrangebyscore",
                        "zincrby",
                        "zdecrby",
                        "zcard",
                        "llen",
                        "lpush",
                        "rpush",
                        "lpop",
                        "rpop",
                        "lrange",
                        "lindex",
                        "exists"
                    }, true);
                    break;
                }
            }

            Store = new RedisDatabase(new ConfigurationOptions
            {
                EndPoints  = { { Context.Configuration.RedisAddress, Context.Configuration.RedisPort } },
                CommandMap = commandMap
            });
        }