|
mod_tile 0.9.1
Renders map tiles with Mapnik and serves them using Apache HTTP Server
|
#include <glib.h>#include <stdio.h>#include "config.h"#include "g_logger.h"#include "store.h"#include "store_memcached.h"#include <libmemcached/memcached.h>#include <limits.h>#include <stdint.h>#include <stdlib.h>#include <string.h>#include <time.h>#include "metatile.h"#include "render_config.h"Functions | |
| static char * | memcached_xyzo_to_storagekey (const char *xmlconfig, const char *options, int x, int y, int z, char *key) |
| Format the Memcached object key for a metatile given (xmlconfig, options, x, y, z). | |
| static char * | memcached_xyz_to_storagekey (const char *xmlconfig, int x, int y, int z, char *key) |
| Format the Memcached object key for an unparameterized metatile. | |
| static int | memcached_tile_read (struct storage_backend *store, const char *xmlconfig, const char *options, int x, int y, int z, char *buf, size_t sz, int *compressed, char *log_msg) |
| Fetch a metatile object from Memcached and extract a single sub-tile payload. | |
| static struct stat_info | memcached_tile_stat (struct storage_backend *store, const char *xmlconfig, const char *options, int x, int y, int z) |
| Retrieve stored metadata, timestamps, and expiry status for a tile in Memcached. | |
| static char * | memcached_tile_storage_id (struct storage_backend *store, const char *xmlconfig, const char *options, int x, int y, int z, char *string) |
| Format a human-readable memcached:/// storage URI identifying (x, y, z). | |
| static int | memcached_metatile_write (struct storage_backend *store, const char *xmlconfig, const char *options, int x, int y, int z, const char *buf, int sz) |
| Store a serialized metatile buffer in Memcached prefixed with struct stat_info. | |
| static int | memcached_metatile_delete (struct storage_backend *store, const char *xmlconfig, int x, int y, int z) |
| Delete the cached metatile entry containing (x, y, z) from Memcached. | |
| static int | memcached_metatile_expire (struct storage_backend *store, const char *xmlconfig, int x, int y, int z) |
| Mark a cached metatile entry in Memcached as expired without evicting it. | |
| static int | memcached_close_storage (struct storage_backend *store) |
| Release the memcached_st client handle associated with a Memcached storage backend. | |
| struct storage_backend * | init_storage_memcached (const char *connection_string) |
| Allocate and initialize a Memcached metatile storage_backend. | |
| struct storage_backend * init_storage_memcached | ( | const char * | connection_string | ) |
Allocate and initialize a Memcached metatile storage_backend.
Parses connection_string of the form "memcached://" (defaulting to "--server=localhost") or "memcached://<host[:port]>" (translated to "--server=<host[:port]>"), constructs a memcached_st handle via memcached(), and wires all backend operation function pointers. Returns NULL if compiled without HAVE_LIBMEMCACHED or if initialization fails.
| connection_string | Backend URI starting with "memcached://". |
|
static |
Release the memcached_st client handle associated with a Memcached storage backend.
| store | Storage backend instance to close. |
|
static |
Delete the cached metatile entry containing (x, y, z) from Memcached.
| store | Initialized memcached storage_backend. |
| xmlconfig | Logical map style name. |
| x | Tile X coordinate. |
| y | Tile Y coordinate. |
| z | Tile zoom level. |
|
static |
Mark a cached metatile entry in Memcached as expired without evicting it.
Fetches the existing cached blob, sets expired = 1 in its leading struct stat_info header, and writes the updated blob back via memcached_replace() so mod_tile can serve stale tiles while triggering background re-rendering.
| store | Initialized memcached storage_backend. |
| xmlconfig | Logical map style name. |
| x | Tile X coordinate. |
| y | Tile Y coordinate. |
| z | Tile zoom level. |
|
static |
Store a serialized metatile buffer in Memcached prefixed with struct stat_info.
Prepends a freshly initialized struct stat_info (with expired = 0 and current timestamps) ahead of buf, writes the combined blob via memcached_set() with no expiration (0), and flushes libmemcached client buffers.
| store | Initialized memcached storage_backend. |
| xmlconfig | Logical map style name. |
| options | Style parameterization options string (currently unused in key formatting). |
| x | Top-left tile X coordinate of the metatile. |
| y | Top-left tile Y coordinate of the metatile. |
| z | Tile zoom level. |
| buf | Serialized metatile buffer (meta_layout + index table + tile payloads). |
| sz | Total byte length of buf. |
|
static |
Fetch a metatile object from Memcached and extract a single sub-tile payload.
Retrieves the cached blob (which begins with a struct stat_info prefix followed by struct meta_layout and the sub-tile index/payloads), validates the metatile magic signature and tile count, and copies the requested sub-tile bytes into buf.
| store | Initialized memcached storage_backend (storage_ctx holds memcached_st *). |
| xmlconfig | Logical map style name. |
| options | Style parameterization options string. |
| x | Global tile X coordinate. |
| y | Global tile Y coordinate. |
| z | Tile zoom level. |
| buf | Caller-supplied output buffer receiving the sub-tile image bytes. |
| sz | Maximum capacity of buf in bytes. |
| compressed | Output flag set to 1 if META_MAGIC_COMPRESSED is present, 0 otherwise. |
| log_msg | Caller-supplied buffer receiving an error message on failure. |
|
static |
Retrieve stored metadata, timestamps, and expiry status for a tile in Memcached.
Reads the cached metatile blob from Memcached, unpacks the leading struct stat_info, and sets tile_stat.size to the individual sub-tile's byte size (or -1 on cache miss).
| store | Initialized memcached storage_backend. |
| xmlconfig | Logical map style name. |
| options | Style parameterization options string. |
| x | Global tile X coordinate. |
| y | Global tile Y coordinate. |
| z | Tile zoom level. |
|
static |
Format a human-readable memcached:/// storage URI identifying (x, y, z).
| store | Initialized memcached storage_backend (unused). |
| xmlconfig | Logical map style name. |
| options | Style parameterization options string (currently unused). |
| x | Tile X coordinate. |
| y | Tile Y coordinate. |
| z | Tile zoom level. |
| string | Caller-supplied output buffer (PATH_MAX bytes) receiving the formatted URI. |
|
static |
Format the Memcached object key for an unparameterized metatile.
Convenience wrapper around memcached_xyzo_to_storagekey() with empty options ("").
| xmlconfig | Logical map style name. |
| x | Global tile X coordinate. |
| y | Global tile Y coordinate. |
| z | Tile zoom level. |
| key | Caller-supplied output buffer (PATH_MAX bytes) receiving the formatted key. |
|
static |
Format the Memcached object key for a metatile given (xmlconfig, options, x, y, z).
Masks x and y down to the top-left (0, 0) corner of their METATILE x METATILE block and formats key as "<xmlconfig>/<x>/<y>/<z>[.<options>].meta".
| xmlconfig | Logical map style name. |
| options | Style parameterization options string (omitted from key if empty). |
| x | Global tile X coordinate. |
| y | Global tile Y coordinate. |
| z | Tile zoom level. |
| key | Caller-supplied output buffer (PATH_MAX bytes) receiving the formatted key. |