Re: What is the contract of a cache backend regarding errors?

2016-12-26 Thread Adam Johnson
Hi Jean,

I wrote a cache backend for MySQL in Django-MySQL and didn't add any
special error handling. Like the builtin database cache backend, it uses
the same connection as the ORM, so if an error does occur it's pretty
likely the whole request is broken anyway.

If you look at the code, Django's memcache backend makes no contract about
errors, delegating that to the underlying library:
https://github.com/django/django/blob/master/django/core/cache/backends/memcached.py
. So I think all three points of your understanding are more to do with how
python-memcached works rather than a contract Django enforces. If you check
the other cache backends where all the logic is in Django, such as
filebased, they don't silence any unexpected errors.

Adam




On 25 December 2016 at 13:50, Jean Hominal  wrote:

> Hello,
>
> I am considering writing a cache backend for Django based on a recent
> Couchbase SDK (2.0+).
>
> While it is quite straightforward to write, I would like to know what is
> expected from a cache backend when errors happen.
>
> With my experience using the python-memcached backend, my understanding is
> that:
>
>  * On read operations, any errors result in a "None" return value (as if
> the value was not found);
>  * On write operations, errors are silenced, with one exception;
>  * On an "add" operation, if e.g. a network error has happened, "0" is
> returned instead of "False". That lets a client make a distinction between
> such errors and the key already existing.
>
> Is that understanding accurate? In particular, is the third point
> contractual?
>
> Thank you in advance.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django developers (Contributions to Django itself)" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-developers+unsubscr...@googlegroups.com.
> To post to this group, send email to django-developers@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-developers.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-developers/12bdf965-eba7-4f81-8ce0-
> bd8803d4d726%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Adam

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/CAMyDDM3%2B2XjMxSvESy5RE9cDTc5O9tw48jzT5CAWYDk-Qtr8yA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


What is the contract of a cache backend regarding errors?

2016-12-25 Thread Jean Hominal
Hello,

I am considering writing a cache backend for Django based on a recent 
Couchbase SDK (2.0+).

While it is quite straightforward to write, I would like to know what is 
expected from a cache backend when errors happen.

With my experience using the python-memcached backend, my understanding is 
that:

 * On read operations, any errors result in a "None" return value (as if 
the value was not found);
 * On write operations, errors are silenced, with one exception;
 * On an "add" operation, if e.g. a network error has happened, "0" is 
returned instead of "False". That lets a client make a distinction between 
such errors and the key already existing.

Is that understanding accurate? In particular, is the third point 
contractual?

Thank you in advance.

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/12bdf965-eba7-4f81-8ce0-bd8803d4d726%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.