-
Notifications
You must be signed in to change notification settings - Fork 306
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4306 from aronasorman/optimizations
Use SQLiteDict for the content cache.
- Loading branch information
Showing
6 changed files
with
73 additions
and
31 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
kalite/distributed/management/commands/create_content_db.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from django.core.management.base import BaseCommand, CommandError | ||
from django.conf import settings | ||
import os | ||
import json | ||
from sqlitedict import SqliteDict | ||
|
||
logging = settings.LOG | ||
|
||
|
||
class Command(BaseCommand): | ||
|
||
def handle(self, *args, **options): | ||
logging.info("Converting...") | ||
|
||
convert(settings.CONTENT_FILEPATH, settings.CONTENT_CACHE_FILEPATH) | ||
|
||
|
||
def convert(jsonfilepath, sqlitefilepath): | ||
with open(jsonfilepath) as f: | ||
items = json.load(f) | ||
|
||
with SqliteDict(sqlitefilepath) as kalitedict: | ||
kalitedict.update(items) | ||
kalitedict.commit() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters