示例#1
0
        /// <summary>
        /// Gets the value with the specified key if it exists, or creates it if it doesn't.
        /// </summary>
        /// <typeparam name="T">Type of the value that was saved</typeparam>
        public static T GetOrAdd <T>(this IKeyValueStore kvStore, string key, Func <T> valueFactory)
        {
            if (kvStore.Exists(key))
            {
                return(kvStore.Get <T>(key));
            }

            var value = valueFactory();

            kvStore.Set(key, value);
            return(value);
        }
示例#2
0
        internal virtual bool GraphNodeExists(Identity id)
        {
            var exists = _storage.Exists(id);

            if (exists == false && _lazyLoader != null)
            {
                // Lazy loading
                LoadNodes(new Query {
                    SingleId = id
                }, MergeOption.AppendOnly, _lazyLoader, true).Wait();
            }
            return(exists);
        }
 public override bool IsDeleted(Identity id)
 {
     return(_deletedElements.Exists(id));
 }
示例#4
0
 public bool ContainsBlockStates(HashDigest <SHA256> blockHash)
 {
     return(_stateHashKeyValueStore.Exists(blockHash.ToByteArray()));
 }
示例#5
0
 public bool Exists(byte[] key)
 {
     return(_cache.ContainsKey(key) || _keyValueStore.Exists(key));
 }