C API

Brian Aker brian@tangent.org
Fri, 16 Jan 2004 09:06:16 -0800


I posted this last night to my blog and decided to repost it here to get
a little more feedback (and possibly some suggestions on the API):

Thus far I have something like this:

void connect_memcached();
void stats_memcached();
void delete_memcached(const char *key, time_t seconds);
void add_memcached(const char *key, int flags, time_t seconds, const
char *data, size_t data_len);
void replace_memcached(const char *key, int flags, time_t seconds, const
char *data, size_t data_len);
void set_memcached(const char *key, int flags, time_t seconds, const
char *data, size_t data_len);
void get_memcached(const char *key);
void close_memcached();


I am thinking about defining some sort of client structure that will be
passed into connect_memcached().
Store in it:
socket
buffer
some sort of len about the data in the buffer

"buffer" I would like to define.... not sure what. Part of me is tempted
to define it as default tcp packet size so that I know I am fetching all
data each read. 

Need to add a fetch method where you pass in buffer and I then copy from
client structure. Dealing with multiple get requests is somewhat of a
pain I might add.

Same with error messages since they are completely made up of strings
(do a bunch of strcmp and return integer equivs?).

Memecache's protocol is a half text/half binary protocol. Shame its not
a complete binary protocol since I could avoid a bit of parsing that
way. Though its text base it has no parser and its not very wordy (I
have to say I have become accustom to just pulling out YACC/LEX and
going to town (though I am becoming fond of PCCTS)).

No authentication currently. 

Trying to avoid malloc() calls since they basically suck for
performance. 

Need to think a bit a more on the stats method too...

-- 
_______________________________________________________
Brian "Krow" Aker, brian@tangent.org
Seattle, Washington
http://krow.net/
http://askbrian.org/
_______________________________________________________
You can't grep a dead tree.