Skip to content
Extraits de code Groupes Projets
Vérifiée Valider 9901d2eb rédigé par Kubat's avatar Kubat
Parcourir les fichiers

CACHE: Cache only non-cached karas with the caching thread

parent 2704e311
Aucune branche associée trouvée
Aucune étiquette associée trouvée
1 requête de fusion!157Caching for karas & refactor & others
......@@ -65,7 +65,7 @@ bool database_get_kara_mtime_path (volatile sqlite3 *db, char filepath[PATH_MA
bool database_get_kara_duration_path(volatile sqlite3 *db, char filepath[PATH_MAX], uint64_t *duration);
void database_cache_kara (volatile sqlite3 *db, int id);
void database_get_all_kara(volatile sqlite3 *db, int **ret_ids, size_t *ret_ids_len);
void database_get_all_non_cached_kara(volatile sqlite3 *db, int **ret_ids, size_t *ret_ids_len);
/* Update the database. */
bool database_update (volatile sqlite3 *db, const char *kara_dir, int check_timestamp);
......
......@@ -180,14 +180,20 @@ ___caching_walker(void *args)
size_t ids_count = 0;
int *ids = NULL;
database_get_all_kara(db, &ids, &ids_count);
database_get_all_non_cached_kara(db, &ids, &ids_count);
if (ids == NULL || ids_count == 0) {
LOG_ERROR("CACHING", "No kara present in the database, exit caching thread");
return NULL;
}
free(ids);
LOG_INFO("CACHE", "Begin to cache %ld karas", ids_count);
for (size_t index = 0; index < ids_count; ++index) {
database_cache_kara(db, ids[index]);
}
LOG_INFO("CACHE", "Finished caching %ld karas", ids_count);
free(ids);
return NULL;
}
......
......@@ -399,10 +399,10 @@ error:
}
void
database_get_all_kara(volatile sqlite3 *db, int **ret_ids, size_t *ret_ids_len)
database_get_all_non_cached_kara(volatile sqlite3 *db, int **ret_ids, size_t *ret_ids_len)
{
static const char *SQL_DATA = "SELECT id FROM kara;";
static const char *SQL_COUNT = "SELECT count(id) FROM kara;";
static const char *SQL_DATA = "SELECT id FROM kara WHERE cached_mtime = 0 OR cached_duration = 0;";
static const char *SQL_COUNT = "SELECT count(id) FROM kara WHERE cached_mtime = 0 OR cached_duration = 0;";
sqlite3_stmt *stmt = NULL;
size_t index = 0;
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter