/// <summary>
 /// 判断KEY是否存在
 /// </summary>
 /// <typeparam name="T">泛型</typeparam>
 /// <param name="id">KeyId</param>
 /// <returns>是否存在</returns>
 /// 时间:2016/8/4 15:17
 /// 备注:
 public bool ContainsKey <T>(string id)
     where T : IHasId <string>
 {
     using (IRedisClient redisClient = PRM.GetClient())
     {
         using (IRedisTypedClient <T> typedclient = redisClient.As <T>())
         {
             string _key = string.Format("urn:{0}:{1}", typeof(T).Name.ToLower(), id);
             return(typedclient.ContainsKey(_key));
         }
     }
 }
Exemplo n.º 2
0
        public bool setCliente(teste _teste)
        {
            using (var redis = this.GetRedisClient()){
                IRedisTypedClient <teste> res = redis.As <teste>() as IRedisTypedClient <teste>;

                if (!res.ContainsKey(_teste.Id))
                {
                    res.Store(_teste, new TimeSpan(0, 0, 0, 0));
                    res.Save();
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Returns true if the given object exists.
        /// </summary>
        /// <param name="id"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        private bool Exist(long id, OsmGeoType type)
        {
            switch (type)
            {
            case OsmGeoType.Node:
                string nodeKey = PrimitiveExtensions.BuildNodeRedisKey(id);
                return(_clientNode.ContainsKey(nodeKey));

            case OsmGeoType.Way:
                string wayKey = PrimitiveExtensions.BuildWayRedisKey(id);
                return(_clientWay.ContainsKey(wayKey));

            case OsmGeoType.Relation:
                string relationKey = PrimitiveExtensions.BuildRelationRedisKey(id);
                return(_clientRelation.ContainsKey(relationKey));
            }
            throw new ArgumentOutOfRangeException("type");
        }