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

subject cache #361

Open
SteveClement opened this issue Sep 3, 2021 · 1 comment
Open

subject cache #361

SteveClement opened this issue Sep 3, 2021 · 1 comment

Comments

@SteveClement
Copy link

  • wanikani_api version: latest
  • Python version: 3.8.10
  • Operating System: win10 (pyCharm)

Description

I have the feeling that the subject cache is not being used as every time I load a subject it queries the API.

What I Did

Iterate over a list of radical IDs and store them in a subjects dict.

I assume this: subject = client.subject(id)
Uses the cache if available, but it is super slow and seems to query WK.

client = Client(v2_api_key, subject_cache_enabled=True)

radicals = client.subjects(levels=1, types='radical')

for radical in radicals:
    rad_list.append(radical.id)

subjects = {}

def generate_items():
    for id in rad_list:
        subject = client.subject(id)
        if not subject.characters == None:
            subjects[str(id)] = [subject.characters]
    return subjects
@tadgh
Copy link
Collaborator

tadgh commented Sep 3, 2021

Heya! Honestly, it's been a long time since I wrote this! Let me dig into the code and get back to you :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants