libmemcached api

Started by Jeff, July 21, 2008, 01:09:29 PM

Previous topic - Next topic

Jeff

I've added a module to use the libmemcached C/C++ library to Artful Code.  It's a dev release, but the functions that are finished are working reliably.



http://static.artfulcode.net/newlisp/memcached.lsp.html">http://static.artfulcode.net/newlisp/memcached.lsp.html


Quotememcached is a high-performance, distributed memory object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load.
Jeff

=====

Old programmers don\'t die. They just parse on...



http://artfulcode.net\">Artful code

cormullion

#1
Good work Jeff - you're really productive at the moment! I'm struggling to keep up with you...

Jeff

#2
Actually, I've just been documenting and posting a lot of the code that I've got lying around :)
Jeff

=====

Old programmers don\'t die. They just parse on...



http://artfulcode.net\">Artful code

methodic

#3
Hi Jeff.



Thanks for the code... unfortunately I don't seem to be able to get it working correctly under 10.1.7. I load the .lsp file, do a memcached:init, memcached:add-server (I know the server is running and works)... and then when I do a memcached:get-key <some_key> that I know for sure doesn't exist, the function returns true.


> (load "memcached.lsp")
MAIN
> (memcached:init)
true
> (memcached:add-server "localhost" 11211)
true
> (memcached:get-key "doesnt_exist")
true


Am I doing something wrong/stupid? :)

Jeff

#4
Without checking the code again, it looks like you are doing things right. Unfortunately, I do not have a lot of time for personal projects at the moment. If you can find the bug and fix it, I would be happy to update the sources on my site and google projects.
Jeff

=====

Old programmers don\'t die. They just parse on...



http://artfulcode.net\">Artful code

methodic

#5
Sure, I will dig into it and see what's going on. I just wanted to make sure it wasn't PEBKAC. :)

methodic

#6
Hey Jeff:



This seems to work for me:
(define (get-key key , res (value-length 0) (flags 0))
  (when MEMCACHED
    (setq res (memcached_get MEMCACHED
                             key (length key)
                             (address value-length)
                             (address flags)
                             (address MEMCACHED_RETURN)))
    ;(unless (zero? res) (get-string res))))
    (if (zero? res)
      nil
      (get-string res))))

I commented out the unless in case you wanted to format it differently.

> (load "memcached.lsp")
MAIN
> (memcached:init)
true
> (memcached:add-server "localhost" 11211)
true
>  (memcached:get-key "TEST")
nil
>  (memcached:set-key "TEST" "testing" 60)
"testing"
>  (memcached:get-key "TEST")
"testing"
> (sleep 60000)
60000
>  (memcached:get-key "TEST")
nil


Hope this was helpful, thanks!!