// Create a new record, prepending the prefix to the key if necessary, optionally setting only the given properties
// This function returns an error if the record already exists
481318
func (s *RedisMapStore) Create(key string, value interface{}, properties ...string) error {
	key, vmap, err := s.prepare(key, value, properties...)
	if err != nil {
		return err
	}
	if len(vmap) == 0 {
		return nil
	}
	err = s.client.Watch(func(tx *redis.Tx) error {
		exists, err := tx.Exists(key).Result()
		if err != nil {
			return err
		}
		if exists {
			return errors.NewErrAlreadyExists(key)
		}
		_, err = tx.Pipelined(func(pipe *redis.Pipeline) error {
			pipe.HMSet(key, vmap)
			return nil
		})
		if err != nil {
			return err
		}
		return nil
	}, key)
	if err != nil {
		return err
	}
	return nil
}
579542
func (record *PreKeyRecord) Serialize() ([]byte, error) {
	b, err := proto.Marshal(record.Pkrs)
	if err != nil {
		return nil, err
	}
	return b, nil
}
821174
func (c *Credentials) Create(ctx context.Context, creds []envelope.CredentialInf) ([]*envelope.Credential, error) {
	resp := []*envelope.Credential{}
	err := c.client.RoundTrip(ctx, "POST", "/credentials", nil, creds, &resp)
	return resp, err
}
89279
func (c *Cacher) Create(ctx context.Context, key string, obj, out runtime.Object, ttl uint64) error {
	return c.storage.Create(ctx, key, obj, out, ttl)
}
230896
func (client *Client) CreateRecord(ctx context.Context, name string, rec DNSRecord) (*DNSRecord, error) {
	body, err := json.Marshal(DNSRecordResponse{
		Record: rec,
	})
	if err != nil {
		return nil, err
	}

	resp, err := client.dnsRequest(ctx, "/v1/domains/"+name+"/records", nil, string(body), "POST")
	if err != nil {
		return nil, err
	}

	var r DNSRecordResponse
	if err = json.Unmarshal(resp, &r); err != nil {
		return nil, err
	}

	return &(r.Record), nil
}
883639
func GeneratePreKeys(start, count int) []*PreKeyRecord {
	records := make([]*PreKeyRecord, count)
	for i := 0; i < count; i++ {
		records[i] = NewPreKeyRecord(uint32(start+i), NewECKeyPair())
	}
	return records
}
455085
func (b *DynamoDBBackend) Create(ctx context.Context, item backend.Item) (*backend.Lease, error) {
	err := b.create(ctx, item, modeCreate)
	if trace.IsCompareFailed(err) {
		err = trace.AlreadyExists(err.Error())
	}
	if err != nil {
		return nil, trace.Wrap(err)
	}
	return b.newLease(item), nil
}
1000924
func (t *tableCommon) RecordKey(h int64) kv.Key {
	return tablecodec.EncodeRecordKey(t.recordPrefix, h)
}
238358
func (r *Record) Assign(expr string) error {
	pair := strings.SplitN(expr, "=", 2)
	if len(pair) < 2 || pair[0] == "" || pair[1] == "" {
		return fmt.Errorf("Record assign '%s' not in correct format. Expected: key=value", expr)
	}

	if strings.HasPrefix(pair[0], "_") {
		return fmt.Errorf("Cannot set data with reserved key: %s", pair[0])
	}

	r.Set(pair[0], pair[1])
	return nil
}
1143388
func (r *BindingREST) Create(ctx context.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, options *metav1.CreateOptions) (out runtime.Object, err error) {
	binding := obj.(*api.Binding)

	// TODO: move me to a binding strategy
	if errs := validation.ValidatePodBinding(binding); len(errs) != 0 {
		return nil, errs.ToAggregate()
	}

	if createValidation != nil {
		if err := createValidation(binding.DeepCopyObject()); err != nil {
			return nil, err
		}
	}

	err = r.assignPod(ctx, binding.Name, binding.Target.Name, binding.Annotations, dryrun.IsDryRun(options.DryRun))
	out = &metav1.Status{Status: metav1.StatusSuccess}
	return
}
1184007
func NewKey() (key *Key, err error) {
	priv, pub, err := native.GenerateKeyPair("")
	if err != nil {
		return nil, trace.Wrap(err)
	}

	return &Key{
		Priv: priv,
		Pub:  pub,
	}, nil
}
1172741
func (r *Record) Create(recordInfo Info, args ...string) (status *Status, err error) {
	switch len(args) {
	case 0:
		_, err = r.Post(r.uri("/records"), recordInfo, &status)
	case 1:
		_, err = r.Post(r.uri("/records/%s", args...), recordInfo, &status)
	case 2:
		_, err = r.Post(r.uri("/records/%s/%s", args...), recordInfo, &status)
	default:
		err = r.formatCallError("Create", args...)
	}
	return
}
721056
func (db *Database) Create() error {
	resp := &struct {
		Error  string `json:"error"`
		Reason string `json:"reason"`
		Ok     bool   `json:"ok"`
	}{}

	body, err := db.Req.Put("")
	err = json.Unmarshal(body, resp)
	if err != nil {
		return err
	}

	if resp.Error != "" {
		return errors.New(resp.Error + " " + resp.Reason)
	}
	if !resp.Ok {
		return errors.New("Couch returned failure when creating [" + db.Name + "]")
	}

	return nil
}
1366782
func (tx *tx) create(table string, o api.StoreObject) error {
	if tx.lookup(table, indexID, o.GetID()) != nil {
		return ErrExist
	}

	copy := o.CopyStoreObject()
	meta := copy.GetMeta()
	if err := touchMeta(&meta, tx.curVersion); err != nil {
		return err
	}
	copy.SetMeta(meta)

	err := tx.memDBTx.Insert(table, copy)
	if err == nil {
		tx.changelist = append(tx.changelist, copy.EventCreate())
		o.SetMeta(meta)
	}
	return err
}
1269254
func createRecord(c *godo.Client, zoneName string, createRequest *godo.DomainRecordEditRequest) error {
	_, _, err := c.Domains.CreateRecord(context.TODO(), zoneName, createRequest)
	if err != nil {
		return fmt.Errorf("error creating record: %v", err)
	}

	return nil
}
1093015
func (h *BindHandle) AddBindRecord(record *BindRecord) (err error) {
	exec, _ := h.sctx.Context.(sqlexec.SQLExecutor)
	h.sctx.Lock()
	_, err = exec.Execute(context.TODO(), "BEGIN")
	if err != nil {
		h.sctx.Unlock()
		return
	}

	defer func() {
		if err != nil {
			_, err1 := exec.Execute(context.TODO(), "ROLLBACK")
			h.sctx.Unlock()
			terror.Log(err1)
			return
		}

		_, err = exec.Execute(context.TODO(), "COMMIT")
		h.sctx.Unlock()
		if err != nil {
			return
		}

		// Make sure there is only one goroutine writes the cache and use parser.
		h.bindInfo.Lock()
		// update the BindMeta to the cache.
		hash, meta, err1 := h.newBindMeta(record)
		if err1 != nil {
			err = err1
			h.bindInfo.Unlock()
			return
		}

		h.appendBindMeta(hash, meta)
		h.bindInfo.Unlock()
	}()

	// remove all the unused sql binds.
	_, err = exec.Execute(context.TODO(), h.deleteBindInfoSQL(record.OriginalSQL, record.Db))
	if err != nil {
		return err
	}

	txn, err1 := h.sctx.Context.Txn(true)
	if err1 != nil {
		return err1
	}
	record.CreateTime = types.Time{
		Time: types.FromGoTime(oracle.GetTimeFromTS(txn.StartTS())),
		Type: mysql.TypeDatetime,
		Fsp:  3,
	}
	record.UpdateTime = record.CreateTime
	record.Status = Using
	record.BindSQL = h.getEscapeCharacter(record.BindSQL)

	// insert the BindRecord to the storage.
	_, err = exec.Execute(context.TODO(), h.insertBindInfoSQL(record))
	return err
}
85330
func (c *Client) CreateRecord(domainID string, record Record) error {
	return c.do(http.MethodPost, fmt.Sprintf("/v1/domains/%s/records", domainID), record, nil)
}