From d97d328fd207e5fc99909de0771b7f2ef5a60a13 Mon Sep 17 00:00:00 2001 From: niamtokik Date: Mon, 19 Apr 2021 19:34:36 +0000 Subject: [PATCH] clean a little bit --- src/redis_command.erl | 66 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 58 insertions(+), 8 deletions(-) diff --git a/src/redis_command.erl b/src/redis_command.erl index 4d8c09f..ba95039 100644 --- a/src/redis_command.erl +++ b/src/redis_command.erl @@ -1,21 +1,38 @@ %%%------------------------------------------------------------------- -%%% @doc +%%% @doc https://redis.io/commands# +%%% +%%% @todo copy +%%% @todo del +%%% @todo set +%%% @todo get +%%% @todo getdel +%%% @todo strlen +%%% @todo append +%%% %%% @end %%%------------------------------------------------------------------- -module(redis_command). --compile(export_all). -compile({no_auto_import,[get/0]}). -include("redis.hrl"). +-export([copy/0, copy/2, copy/3]). +-export([del/0, del/1]). +-export([set/0, set/2, set/3]). +-export([get/0, get/1]). %%-------------------------------------------------------------------- -%% @doc +%% @doc copy/0. %% @end %%-------------------------------------------------------------------- -spec copy() -> Return when Return :: encode_bulk_string(). + copy() -> {bulk_string, <<"COPY">>}. +%%-------------------------------------------------------------------- +%% @doc copy/2. +%% @end +%%-------------------------------------------------------------------- -spec copy(Source, Destination) -> Return when Source :: encode_bulk_string(), Destination :: encode_bulk_string(), @@ -24,67 +41,100 @@ copy() -> copy(Source, Destination) -> copy(Source, Destination, []). +%%-------------------------------------------------------------------- +%% @doc copy/3. +%% @end +%%-------------------------------------------------------------------- -spec copy(Source, Destination, Args) -> Return when Source :: encode_bulk_string(), Destination :: encode_bulk_string(), Args :: list(), Return :: any(). + copy(Source, Destination, _Args) -> Command = [copy(), Source, Destination], redis:encode(Command). %%-------------------------------------------------------------------- -%% @doc +%% @doc del/0. %% @end %%-------------------------------------------------------------------- -spec del() -> Return when - Return :: {bulk_string, bitstring()}. + Return :: encode_bulk_string(). + del() -> {bulk_string, <<"DEL">>}. +%%-------------------------------------------------------------------- +%% @doc del/1. +%% @end +%%-------------------------------------------------------------------- -spec del(Keys) -> Return when Keys :: encode_bulk_string(), Return :: any(). + del(Keys) -> Command = [del()|Keys], redis:encode(Command). %%-------------------------------------------------------------------- -%% @doc +%% @doc set/0. %% @end %%-------------------------------------------------------------------- -spec set() -> Return when Return :: encode_bulk_string(). + set() -> {bulk_string, <<"SET">>}. +%%-------------------------------------------------------------------- +%% @doc set/0. +%% @end +%%-------------------------------------------------------------------- -spec set(Key, Value) -> Return when Key :: encode_bulk_string(), Value :: encode_types(), Return :: any(). + set(Key, Value) -> set(Key, Value, []). +%%-------------------------------------------------------------------- +%% @doc set/0. +%% @end +%%-------------------------------------------------------------------- -spec set(Key, Value, Args) -> Return when Key :: encode_bulk_string(), Value :: encode_types(), Args :: list(), Return :: any(). + set(Key, Value, _Args) -> Command = [set(), Key, Value], redis:encode(Command). %%-------------------------------------------------------------------- -%% @doc +%% @doc get/0. %% @end %%-------------------------------------------------------------------- +-spec get() -> Return when + Return :: encode_bulk_string(). + get() -> {bulk_string, <<"GET">>}. +%%-------------------------------------------------------------------- +%% @doc get/0. +%% @end +%%-------------------------------------------------------------------- +-spec get(Key) -> Return when + Key :: encode_bulk_string(), + Return :: any(). + get(Key) -> Command = [get(), Key], redis:encode(Command). %%-------------------------------------------------------------------- -%% @doc +%% @doc getdel/0. %% @end %%--------------------------------------------------------------------