lib/cache_sqlite.c
mapcache_cache* mapcache_cache_mbtiles_create(mapcache_context *ctx)
{
  mapcache_cache_sqlite *cache = (mapcache_cache_sqlite*) mapcache_cache_sqlite_create(ctx);
  if (!cache) {
    return NULL;
  }
  cache->cache.configuration_post_config = _mapcache_cache_mbtiles_configuration_post_config;
  cache->cache.tile_set = _mapcache_cache_mbtiles_set;
  cache->cache.tile_multi_set = _mapcache_cache_mbtiles_multi_set;
  cache->cache.tile_delete = _mapcache_cache_mbtiles_delete;
  cache->create_stmt.sql = apr_pstrdup(ctx->pool,
                                       "create table if not exists images(tile_id text, tile_data blob, primary key(tile_id));"\
                                       "CREATE TABLE  IF NOT EXISTS map (zoom_level integer, tile_column integer, tile_row integer, tile_id text, foreign key(tile_id) references images(tile_id), primary key(tile_row,tile_column,zoom_level));"\
                                       "create table if not exists metadata(name text, value text);"\
                                       "create view if not exists tiles AS SELECT map.zoom_level AS zoom_level, map.tile_column AS tile_column, map.tile_row AS tile_row, images.tile_data AS tile_data FROM map JOIN images ON images.tile_id = map.tile_id;"
                                      );
  cache->exists_stmt.sql = apr_pstrdup(ctx->pool,
                                       "select 1 from tiles where tile_column=:x and tile_row=:y and zoom_level=:z");
  cache->get_stmt.sql = apr_pstrdup(ctx->pool,
                                    "select tile_data from tiles where tile_column=:x and tile_row=:y and zoom_level=:z");
  cache->delete_stmt.sql = apr_pstrdup(ctx->pool,
                                       "delete from tiles where tile_column=:x and tile_row=:y and zoom_level=:z");
  cache->n_prepared_statements = 9;
  cache->bind_stmt = _bind_mbtiles_params;
  return (mapcache_cache*) cache;
}
/**
 * \brief creates and initializes a mapcache_sqlite_cache
 */
\brief creates and initializes a mapcache_sqlite_cache
\ brief creates and initializes a mapcache_sqlite_cache
mapcache_cache* mapcache_cache_mbtiles_create(mapcache_context *ctx)
{
  mapcache_cache_sqlite *cache = (mapcache_cache_sqlite*) mapcache_cache_sqlite_create(ctx);
  if (!cache) {
    return NULL;
  }
  cache->cache.configuration_post_config = _mapcache_cache_mbtiles_configuration_post_config;
  cache->cache.tile_set = _mapcache_cache_mbtiles_set;
  cache->cache.tile_multi_set = _mapcache_cache_mbtiles_multi_set;
  cache->cache.tile_delete = _mapcache_cache_mbtiles_delete;
  cache->create_stmt.sql = apr_pstrdup(ctx->pool,
                                       "create table if not exists images(tile_id text, tile_data blob, primary key(tile_id));"\
                                       "CREATE TABLE  IF NOT EXISTS map (zoom_level integer, tile_column integer, tile_row integer, tile_id text, foreign key(tile_id) references images(tile_id), primary key(tile_row,tile_column,zoom_level));"\
                                       "create table if not exists metadata(name text, value text);"\
                                       "create view if not exists tiles AS SELECT map.zoom_level AS zoom_level, map.tile_column AS tile_column, map.tile_row AS tile_row, images.tile_data AS tile_data FROM map JOIN images ON images.tile_id = map.tile_id;"
                                      );
  cache->exists_stmt.sql = apr_pstrdup(ctx->pool,
                                       "select 1 from tiles where tile_column=:x and tile_row=:y and zoom_level=:z");
  cache->get_stmt.sql = apr_pstrdup(ctx->pool,
                                    "select tile_data from tiles where tile_column=:x and tile_row=:y and zoom_level=:z");
  cache->delete_stmt.sql = apr_pstrdup(ctx->pool,
                                       "delete from tiles where tile_column=:x and tile_row=:y and zoom_level=:z");
  cache->n_prepared_statements = 9;
  cache->bind_stmt = _bind_mbtiles_params;
  return (mapcache_cache*) cache;
}
mapcache_cache * mapcache_cache_mbtiles_create ( mapcache_context * ctx ) { mapcache_cache_sqlite * cache = ( mapcache_cache_sqlite * ) mapcache_cache_sqlite_create ( ctx ) ; if ( ! cache ) { return NULL ; } cache -> cache . configuration_post_config = _mapcache_cache_mbtiles_configuration_post_config ; cache -> cache . tile_set = _mapcache_cache_mbtiles_set ; cache -> cache . tile_multi_set = _mapcache_cache_mbtiles_multi_set ; cache -> cache . tile_delete = _mapcache_cache_mbtiles_delete ; cache -> create_stmt . sql = apr_pstrdup ( ctx -> pool , " " " " " " " " ) ; cache -> exists_stmt . sql = apr_pstrdup ( ctx -> pool , " " ) ; cache -> get_stmt . sql = apr_pstrdup ( ctx -> pool , " " ) ; cache -> delete_stmt . sql = apr_pstrdup ( ctx -> pool , " " ) ; cache -> n_prepared_statements = 9 ; cache -> bind_stmt = _bind_mbtiles_params ; return ( mapcache_cache * ) cache ; }
\brief creates and initializes a mapcache_sqlite_cache
\ brief creates and initializes a mapcache_sqlite_cache