This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Eric Appelt
Recipients Eric Appelt, Mariatta, barry, docs@python, levkivskyi, martin.panter, vstinner, yselivanov
Date 2017-06-01.01:49:55
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1496281796.69.0.691387293857.issue30145@psf.upfronthosting.co.za>
In-reply-to
Content
> 2b - I propose to take a simple protocol like Memcache or 
> Redis and simply implement it using the streams API.  We’ll only
> need two methods: set and get; and in the end we’ll teach the user
> how things really work and how to design async APIs.

I decided to make myself a test subject for this idea using Redis since although I use Redis a lot at work I've never looked at the underlying Redis protocol. I also haven't used the streams API in a long time, and never for anything other than simple exploration.

I worked on this the other night and found the Redis protocol simple enough to understand and was able to write a simple and somewhat clumsy client the other night with a bit of work: https://gist.github.com/appeltel/09d77eb489494ae1e2703933108cb60a

One thing that might be good about the Redis protocol for this purpose is that the parsing isn't completely trivial but it isn't overly complex either. For example, a response string can be given in either the simple format, which begins with a "+" byte and then terminates with "\r\n", or it can be in a binary safe format where a token of the form "$123\r\n" is sent first, signaling that the next 123 bytes are the result to be followed by another "\r\n" termination. There is also the sentinel value "$-1\r\n" which may signal an unset key. Thus the string "foo" might be sent as "+foo\r\n" or "$3\r\nfoo\r\n".

So I think this can be reasonably described in a few brief paragraphs and it is much more interesting (to me) than an echo client/server example.

The tutorial should probably also include a link to a rudimentary server implementation of an in-memory key/value store implementing the Redis protocol and supporting just GET and SET, as the reader may not be able to easily stand up Redis for a variety of reasons or lack of knowledge.

I can experiment with memcached as well but I think this proposal is a good idea and would work well with Redis.
History
Date User Action Args
2017-06-01 01:49:56Eric Appeltsetrecipients: + Eric Appelt, barry, vstinner, docs@python, martin.panter, yselivanov, levkivskyi, Mariatta
2017-06-01 01:49:56Eric Appeltsetmessageid: <1496281796.69.0.691387293857.issue30145@psf.upfronthosting.co.za>
2017-06-01 01:49:56Eric Appeltlinkissue30145 messages
2017-06-01 01:49:55Eric Appeltcreate