Esempio n. 1
0
// PING
func (m *Redico) cmdPing(out *redeo.Responder, r *redeo.Request) error {
	if !m.handleAuth(r.Client(), out) {
		return nil
	}
	out.WriteInlineString("PONG")
	return nil
}
Esempio n. 2
0
// withTx wraps the non-argument-checking part of command handling code in
// transaction logic.
func withTx(
	m *Redico,
	out *redeo.Responder,
	r *redeo.Request,
	cb txCmd,
) error {
	ctx := getCtx(r.Client())
	if inTx(ctx) {
		addTxCmd(ctx, cb)
		out.WriteInlineString("QUEUED")
		return nil
	}
	m.Lock()
	defer m.Unlock()
	cb(out, ctx)
	return nil
}
Esempio n. 3
0
// TYPE
func (m *Miniredis) cmdType(out *redeo.Responder, r *redeo.Request) error {
	if len(r.Args) != 1 {
		setDirty(r.Client())
		out.WriteErrorString("usage error")
		return nil
	}
	if !m.handleAuth(r.Client(), out) {
		return nil
	}

	key := r.Args[0]

	return withTx(m, out, r, func(out *redeo.Responder, ctx *connCtx) {
		db := m.db(ctx.selectedDB)

		t, ok := db.keys[key]
		if !ok {
			out.WriteInlineString("none")
			return
		}

		out.WriteInlineString(t)
	})
}
Esempio n. 4
0
func pingCmd(out *redeo.Responder, _ *redeo.Request) error {
	out.WriteInlineString("PONG")
	return nil
}
Esempio n. 5
0
// PING
func (m *Miniredis) cmdPing(out *redeo.Responder, r *redeo.Request) error {
	out.WriteInlineString("PONG")
	return nil
}