Ok, i've implemented incr and decr with the following API:
increment by 1: POST
http://cloudcache.ws/<key>/incr ; data is empty
or doesn't contain val or val=1
increment by <val> : POST
http://cloudcache.ws/<key>/incr ; data
contains val=<val>
Likewise for decr.
If key/val doesn't exist in CC, error is returned.
If val exists for key in CC, but val is not numeric, it is set to 1.
If val is 0 when decr called, 0 is returned.
If val is 64-bit unsigned bigint when incr is called, it wraps.
These are all consistent with the memcached server API, which makes
for easy drop-in replacement of potential CloudCache libs in place of
existing memcached libs (requires only a constructor change).
Simple python examples of usage are provide in incr.py and decr.py in
the google-code for cloudcache-python here -
http://code.google.com/p/cloudcache-python/source/browse/trunk/
Cheers,
m
On Feb 6, 11:31 am, Marc Byrd <
m...@cloudscape.ws> wrote:
> I'm inclined to stick w/ post - get is supposed to be safe...
>
> How about post /mycounter/incr , /mycounter/decr , with val passed in via
> data, and if not there, 1 is implied?
>
> m
>
> On Fri, Feb 6, 2009 at 11:08 AM, Travis Reeder <
tree...@gmail.com> wrote:
> > I don't think you should use '+' signs, those are escape characters in
> > URL's. Maybehttp://
cloudcache.ws/mycounter/inc<
http://cloudcache.ws/mycounter++>
> > andhttp://
cloudcache.ws/mycounter/dec<
http://cloudcache.ws/mycounter++>
> > and
> >
http://cloudcache.ws/mycounter/add/3<
http://cloudcache.ws/mycounter++>
> > and
> >
http://cloudcache.ws/mycounter<
http://cloudcache.ws/mycounter++> -
> > returns the value
>
> > I wouldn't worry too much about the post/get thing with something like this
> > though, POST seems overkill.
>
> > Travis
>
> > On Fri, Feb 6, 2009 at 10:58 AM, Marc <
dr.marc.b...@gmail.com> wrote:
>
> >> Also, would be grateful for feedback on most ReSTful way to implement
> >> incr/decr .
>
> >> Here's one idea: POSThttp://
cloudcache.ws/mycounter++and /