예제 #1
0
        public virtual string GetItemKey <T>(string value)
        {
            var pi  = StoreEntityTypesCache.GetTypeKey(typeof(T));
            var key = string.Format("[{0}_{1}:{2}]", typeof(T).Name, pi.Name, value);

            return(key);
        }
예제 #2
0
        public virtual string GetItemKey <T>(T item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("Item cannot be null");
            }

            var pi  = StoreEntityTypesCache.GetTypeKey(typeof(T));
            var key = string.Format("[{0}_{1}:{2}]", typeof(T).Name, pi.Name, GetStringValue(pi.GetValue(item, null)));

            return(key);
        }
예제 #3
0
        public virtual void Set <T>(T item)
        {
            var key = GetItemKey(item);

            // Write value
            Provider.Hash[key].Set(Serialize(item));

            // Write indexes
            var keyvalue = GetStringValue(StoreEntityTypesCache.GetTypeKey(typeof(T)).GetValue(item, null));

            var indexes = StoreEntityTypesCache.GetTypeIndexes(typeof(T));

            if (indexes != null)
            {
                foreach (var idx in indexes.Values)
                {
                    Provider.Set[GetIndexKey(item, idx)].Add(keyvalue);
                }
            }
        }