/// <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); }
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)); }
public bool ContainsBlockStates(HashDigest <SHA256> blockHash) { return(_stateHashKeyValueStore.Exists(blockHash.ToByteArray())); }
public bool Exists(byte[] key) { return(_cache.ContainsKey(key) || _keyValueStore.Exists(key)); }