0

i've been working with php for a while now and have found the memcached library for php. Now i have a search engine in python and i want to cache content from databases written for python interpretation...

I am aware of the mod_python library in apache server.. can i use it some-how to cache stuff?

i mean, once my cache is warm, it should stay warm, as long as the server is powered on.

(Of course, if the server is powered off, the memory is refreshed hence memcached will be refreshed too)

My homework:
I've come across this page: python memcached but i'm not sure if i can use it in conjunction with apache server...

thanks to all who helped...

tenstar
  • 9,816
  • 9
  • 24
  • 45

1 Answers1

0

https://pypi.python.org/pypi/python-memcached/ :

This software is a 100% Python interface to the memcached memory cache daemon. It is the client side software which allows storing values in one or more, possibly remote, memcached servers.

That means that memcached runs as a separate daemon, independent from httpd, and your code can store data in that daemon like in a database. In fact, memcached is nothing else than a NoSQL database.

For a tutorial, see Good examples of python-memcache (memcached) being used in Python? .

Apache has completely nothing to do with this - your code makes its own connection to the daemon.

Community
  • 1
  • 1
ivan_pozdeev
  • 33,874
  • 19
  • 107
  • 152
  • isn't it an in-memory python-dictionary like object? by the way, is there a tutorial on how to use python-memcached in conjunction with apache? if yes please provide links to the site... @ivan_pozdeev – tenstar Jun 17 '13 at 13:39
  • No, it's language-independent. – ivan_pozdeev Jun 17 '13 at 13:53
  • if you please tell me how to install python-memcached, i'll accept your answer... I'm on ubuntu does it have cas support? @ivan_posdeev – tenstar Jun 17 '13 at 13:59
  • as always, `easy_install`, I guess. – ivan_pozdeev Jun 17 '13 at 14:00
  • If you mean `mod_cas`, then the python module is unrelated to it. If you want to wrap `memcached` access into some logic on the client side, make wrappers or replace the module's contents at runtime. If you mean server-side authentication support by `memcached` daemon, it optionally supports SASL authentication but generally, it's designed for speed so I consider it better to make your host/connection trusted by some other means. – ivan_pozdeev Jun 17 '13 at 14:32
  • i have seen that there is a gets method and a cas method, but gets doesn't return the value and a unique as it is supposed to, instead it returns only value – tenstar Jun 17 '13 at 14:39
  • See https://github.com/linsomniac/python-memcached/blob/master/memcache.py for its workings. It looks like it doesn't return cas values but instead caches them if `cache_cas` is true. I dunno why it was made so, perhaps this is a reason for a pull request. – ivan_pozdeev Jun 17 '13 at 14:54
  • so isn't there a way of using cas? @ivan_pozdeev – tenstar Jun 19 '13 at 12:03
  • Hell, patch the module so it returns whatever you need (you need `cas_id` at `memcache.py:860`, I guess). It's open-source, isn't it? Another way is to enable `cache_cas` and get `.cas_ids[key]` after `gets()` - this will work if my assumption that `key` and `rkey` in `_get()` are the same is correct. – ivan_pozdeev Jun 19 '13 at 13:31
  • Are you a Python programmer or what? There's source, there's console for experiments, I've even pinpointed where to look. All else I can do is do your job for you which I'm not going to - not gratis, at least. – ivan_pozdeev Jun 19 '13 at 21:44