Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manage cache #55

Closed
xlcnd opened this issue Jun 4, 2014 · 5 comments
Closed

Manage cache #55

xlcnd opened this issue Jun 4, 2014 · 5 comments
Labels

Comments

@xlcnd
Copy link
Owner

xlcnd commented Jun 4, 2014

Calls to metadata services are cached by default. If you don't want this feature, just enter isbn_conf setopt cache no.

If by any reason you need to clear the cache, just enter isbn_conf delcache.

@xlcnd xlcnd added the info label Jun 4, 2014
xlcnd added a commit that referenced this issue Jun 4, 2014
@Phyks
Copy link

Phyks commented Jul 1, 2014

Hi,

I have an issue with isbntools, used in a program, throught the _dev module : Phyks/BMC#5

When I run fmtbib('bibtex', isbntools.meta(isbn, 'default')) the first time, with a valid isbn, any run after with invalid isbn returns the previous record.

I think it may be linked with this issue. Can you confirm ? And is there a way to disable caching on the developper side (without changing saved user conf) ?

Thanks

@xlcnd
Copy link
Owner Author

xlcnd commented Jul 2, 2014

What version of isbntools are you using? I am not able to reproduce this bug!!! It is very strange indeed because the cache is a dict-like structure whose key is the isbn concatenated with the service's name (in this case the service that is defined as 'default') and has no notion of 'previous'... unless 'previous' is the value for that key... in that case, this is not a bug is a feature!

Anyway, to disable caching, you could read what the option for caching in the conf file is (usersoption = isbntools.config.get('cache')), then disable caching (isbntools.config.set_option('cache', 'no')), do you call to meta, and then write back the user's value for cache (isbntools.config.set_option('cache', usersoption)). However, I don't advise disable caching! Without caching the medata services (WorldCat, Google Books) will block the access, they have very strict rules...

I read your issue Phyks/BMC#5 and I think you have been deceived by the message of the testing framework ... the problem is not caching but an exception that have been thrown by the call to 'foo'... the testing framework just present you with the last captured line in std.out, and so the 'previous` value!

By the way, there is another library isbnlib, based in isbntools but with no config files, no plugins, ... that probably is better suited for your project.

I took a look at your project and it seems very interesting. I have three more suggestions to make, related with the use of isbntools:

  1. Do not make calls to private modules (following the python convention, their names start with '_') use the API (e.g. from isbntools.dev.lab import fmtbib).
  2. Take a look at the methods clean, to_isbn13, get_isbnlike, canonical, and get_canonical_isbn to clean, standardize and extract ISBNs.
  3. Try to use always ISBN-13 (ISBN-10 is deprecated, some ISBNs don't have an ISBN-10 representation) and in the form EAN13.

@xlcnd
Copy link
Owner Author

xlcnd commented Jul 2, 2014

Ooops! I was able to reproduce the problem...

There is a problem with the cache, in some special cases a new record is added to the cache with the wrong key!!!

I opened a new issue (issue #68).

@xlcnd
Copy link
Owner Author

xlcnd commented Jul 2, 2014

The problem seems solved! At least I am not able to reproduce it... the follow up will be in #68.

@Phyks
Copy link

Phyks commented Jul 2, 2014

I understand better the caching, thank you for the explanations. I will avoid caching.

Concerning my issue, I'm not so sure it's just a std.out problem, because I was actually able to reproduce it in top level. But so did you apparently. Actually, I had no problems with the version in the arch repos (3.3.5) but I had problems with the latest version available by pip.

I did not find isbnlib when I was looking for it. It's definitely better for my project and I'll update to use it instead. So I think my issue is solved.

Concerning your remarks about my use of isbntools in my project:

  1. I used to import isbntools.dev.fmt, but it was not exposed anymore in the latest versions. I used the private modules, but thank you for pointing me out the correct API. However, if I move to isbnlib, it will no longer concern my script, I think.
  2. I will take a look at these methods. For now I have a custom regular expression to extract the ISBN from the PDF file, maybe this can be improved. get_isbnlike should do the same, right ?
  3. I use the ISBN as provided in the PDF or by the user. I will convert it to ISBN13 if not already ISBN13. Thanks for the advice.

Thanks

This was referenced Jul 2, 2014
@xlcnd xlcnd closed this as completed Jul 3, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants