www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Redis client

reply Pedro Lacerda <pslacerda gmail.com> writes:
--0015175cd03aa0ce5904ba767950
Content-Type: text/plain; charset=UTF-8

In an attempt to learn D and git I'm building a Redis client. Assertedly
there are many problems in the implementation, I'd like to hear opinions
pointing them or suggestions. If here isn't the place to ask these type of
review, where is?
github.com/pslacerda/dredis

Some friend asked why I choose not to go asynchronous. It's because usually
clients and servers are at a very fast connection and Redis responses are
pretty fast too.

Correct me if wrong, but I need to do nothing special at client.RedisClient
to make it thread safe, right?

token.__Bulk has an nullable array because I made distinction between an
empty and a null arrays as the protocol did. The type looks fully bad. Some
idea?

I guess that make token.Token an struct and pass it through ref functions
will make the code somewhat better, but I have no clues. Token will never
be seen by the user. When should I do it?

I guess that implement the protocol as free functions isn't a bad option
because D offers this imperative style and the protocol is so small that
doesn't need more a structured approach. Tell me this is wrong!


thanks from a newbie :-)
Pedro Lacerda

--0015175cd03aa0ce5904ba767950
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div>In an attempt to learn D and git I&#39;m building a Redis client.=C2=
=A0Assertedly there are many problems in the implementation, I&#39;d like t=
o hear opinions pointing them or suggestions.=C2=A0If here isn&#39;t the pl=
ace to ask these type of review, where is?</div>

<div><a href=3D"http://github.com/pslacerda/dredis">github.com/pslacerda/dr=
edis</a></div><div><br></div><div>Some friend asked why I choose not to go =
asynchronous. It&#39;s because usually clients and servers are at a very fa=
st connection and Redis responses are pretty fast too.</div>

<div><div><br></div><div>Correct me if wrong, but I need to do nothing spec=
ial at client.RedisClient to make it thread safe, right?</div><div><br></di=
v><div>token.__Bulk has an nullable array because I made distinction betwee=
n an empty and a null arrays as the protocol did. The type looks fully bad.=
 Some idea?</div>

<div><br></div><div>I guess that make token.Token an struct and pass it thr=
ough ref functions will make the code somewhat better, but I have no clues.=
 Token will never be seen by the user. When should I do it?</div><div>
<br>
</div><div>I guess that implement the protocol as free functions isn&#39;t =
a bad option because D offers this imperative style and the protocol is so =
small that doesn&#39;t need more a structured approach. Tell me this is wro=
ng!</div>

<div><br></div><div><br></div><div>thanks from a newbie :-)</div><div>Pedro=
 Lacerda</div>
</div>

--0015175cd03aa0ce5904ba767950--
Mar 04 2012
parent Dmitry Olshansky <dmitry.olsh gmail.com> writes:
On 05.03.2012 7:24, Pedro Lacerda wrote:
 In an attempt to learn D and git I'm building a Redis client. Assertedly
 there are many problems in the implementation, I'd like to hear opinions
 pointing them or suggestions. If here isn't the place to ask these type
 of review, where is?
 github.com/pslacerda/dredis <http://github.com/pslacerda/dredis>

You may go for D group, though for newbie kind of thing D.learn is perfect place.
 Some friend asked why I choose not to go asynchronous. It's because
 usually clients and servers are at a very fast connection and Redis
 responses are pretty fast too.

Right, and you always can go fancy later on :)
 Correct me if wrong, but I need to do nothing special at
 client.RedisClient to make it thread safe, right?

plan to go _shared_ it's OK.
 token.__Bulk has an nullable array because I made distinction between an
 empty and a null arrays as the protocol did. The type looks fully bad.
 Some idea?

Just use plain Nullable!(T[]) as is? I mean there is no need to wrap wrapper type ;)
 I guess that make token.Token an struct and pass it through ref
 functions will make the code somewhat better, but I have no clues. Token
 will never be seen by the user. When should I do it?

Make it a struct, from the looks of it it's a tagged union anyway. More importantly passing it _by value_ and copying is far cheaper then allocating new objects and working with them via extra indirection. It would be almost the same as using Algebraic!(string,Exception,long,Bulk,MultiBulk) from std.variant. Though then you'd miss your nice Type enumeration.
 I guess that implement the protocol as free functions isn't a bad option
 because D offers this imperative style and the protocol is so small that
 doesn't need more a structured approach. Tell me this is wrong!

It's up to you in any case. Benefits of extra structure won't show up until the code is quite large.
 thanks from a newbie :-)
 Pedro Lacerda

You are welcome ! -- Dmitry Olshansky
Mar 05 2012