private void CreateRecordIfMissing(AerospikeSettings settings, Key recordKey)
        {
            var client = GetClient(settings);

            if (client.Exists(null, new Key[] { recordKey }[0]))
            {
                return;
            }

            var writePolicy = new WritePolicy()
            {
                recordExistsAction = RecordExistsAction.CREATE_ONLY,
                expiration         = 3600,
                sendKey            = true
            };

            try
            {
                client.Put(writePolicy, recordKey, new Bin[2] {
                    new Bin(Keystore.AerospikeKeys.BinNames.ReadLocks, 0),
                    new Bin(Keystore.AerospikeKeys.BinNames.WriteLocks, 0)
                });
            }
            catch (AerospikeException aex)
            {
                if (aex.Result != 5)
                {
                    throw;
                }
            }
        }
示例#2
0
 private AsyncClient GetClient(AerospikeSettings settings)
 {
     return(_clientFactory.GetClient(settings.Host, settings.Port, settings.SecondaryHosts));
 }
 private Key GetAlertnateRecordKey(AerospikeSettings settings, string stateId)
 {
     return(new Key(settings.SecondaryNamespace, settings.Set, Value.Get(stateId)));
 }
 internal Key GetRecordKey(AerospikeSettings settings, string counterId)
 {
     return(new Key(settings.Namespace, settings.Set, Value.Get(counterId)));
 }
 internal async Task <Key> GetRecordKey(AerospikeSettings settings, string stateId)
 {
     return(new Key(settings.Namespace, settings.Set, Value.Get(stateId)));
 }