pattern.web.cache

44 views
Skip to first unread message

patternrookie

unread,
Mar 26, 2013, 2:17:46 PM3/26/13
to pattern-f...@googlegroups.com
hi!
I use the pattern.web module in a script. I use this script to search with search engines, retrieve urls and then download them (pattern.web.url.download).

Because there is the possibility that this script will do the same search engine query more than once, i would prefe to cache the results. It decreases the number of search engine hits and therefore it does charge less of my search engine account credits (for example google charges 5$ per 1000 hits).

In the web module says:
try:
    # Import persistent Cache.
    # If this module is used separately, a dict is used (i.e. for this Python session only).
    from cache import Cache, cache, TMP
except:
    cache = {}

So my cache is only stored in the memory. Every time I start the script again, the cache is empty. Is there a way to make the cache permanent and also control myself when to delete older cache entries?

cheerio!

Tom De Smedt

unread,
Mar 26, 2013, 6:38:51 PM3/26/13
to pattern-f...@googlegroups.com
Can you check whether the cache is a Cache object or a plain dict?

from pattern.web import cache
print cache.__class__

If it this a plain dict, can you take the code you highlighted out of the try/except block and see what error is raised?

Best,
Tom
--
 
---
You received this message because you are subscribed to the Google Groups "Pattern" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pattern-for-pyt...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

patternrookie

unread,
Mar 30, 2013, 4:06:18 AM3/30/13
to pattern-f...@googlegroups.com
The import of the cache and the print brings the output: <type 'dict'>.
So it is only in the memory.
Reply all
Reply to author
Forward
0 new messages