Skip to content

Commit a440cd3

Browse files
authored
LMDB cache backend (#293)
1 parent 4c74280 commit a440cd3

File tree

7 files changed

+530
-2
lines changed

7 files changed

+530
-2
lines changed

CMakeLists.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ option(WITH_PIXMAN "Use pixman for SSE optimized image manipulations" ON)
9090
option(WITH_SQLITE "Use sqlite as a cache/dimension backend" ON)
9191
option(WITH_POSTGRESQL "Use PostgreSQL as a dimension backend" OFF)
9292
option(WITH_BERKELEY_DB "Use Berkeley DB as a cache backend" OFF)
93+
option(WITH_LMDB "Use LMDB as a cache backend" OFF)
9394
option(WITH_MEMCACHE "Use memcache as a cache backend (requires recent apr-util)" OFF)
9495
option(WITH_REDIS "Use redis as a cache backend (requires hiredis library)" OFF)
9596
option(WITH_TIFF "Use TIFFs as a cache backend" OFF)
@@ -240,6 +241,20 @@ if(WITH_BERKELEY_DB)
240241
endif(BERKELEYDB_FOUND)
241242
endif (WITH_BERKELEY_DB)
242243

244+
if(WITH_LMDB)
245+
if(NOT LMDB_FIND_VERSION)
246+
set(LMDB_FIND_VERSION "0.9.10")
247+
endif(NOT LMDB_FIND_VERSION)
248+
find_package(LMDB)
249+
if(LMDB_FOUND)
250+
include_directories(${LMDB_INCLUDE_DIR})
251+
target_link_libraries(mapcache ${LMDB_LIBRARY})
252+
set(USE_LMDB 1)
253+
else(LMDB_FOUND)
254+
report_optional_not_found(LMDB)
255+
endif(LMDB_FOUND)
256+
endif(WITH_LMDB)
257+
243258
if(WITH_TIFF)
244259
find_package(TIFF)
245260
if(TIFF_FOUND)
@@ -335,6 +350,7 @@ status_optional_component("PIXMAN" "${USE_PIXMAN}" "${PIXMAN_LIBRARY}")
335350
status_optional_component("SQLITE" "${USE_SQLITE}" "${SQLITE_LIBRARY}")
336351
status_optional_component("POSTGRESQL" "${USE_POSTGRESQL}" "${PostgreSQL_LIBRARY}")
337352
status_optional_component("Berkeley DB" "${USE_BDB}" "${BERKELEYDB_LIBRARY}")
353+
status_optional_component("LMDB" "${USE_LMDB}" "${LMDB_LIBRARY}")
338354
status_optional_component("Memcache" "${USE_MEMCACHE}" "${APU_LIBRARY}")
339355
status_optional_component("Redis" "${USE_REDIS}" "${HIREDIS_LIBRARIES} ${HIREDIS_INCLUDE_DIR}")
340356
status_optional_component("TIFF" "${USE_TIFF}" "${TIFF_LIBRARY}")

cmake/FindLMDB.cmake

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
set(LMDB_FOUND TRUE)
2+
3+
set(LMDB_INC_SEARCH_PATH "/usr/include")
4+
set(LMDB_LIB_SEARCH_PATH "/usr/lib")
5+
6+
find_path(LMDB_INCLUDE_DIR NAMES "lmdb.h" HINTS ${LMDB_INC_SEARCH_PATH})
7+
find_library(LMDB_LIBRARY NAMES "lmdb" HINTS ${LMDB_LIB_SEARCH_PATH})
8+
9+
set(LMDB_INCLUDE_DIRS ${LMDB_INCLUDE_DIR})
10+
set(LMDB_LIBRARIES ${LMDB_LIBRARY})
11+
include(FindPackageHandleStandardArgs)
12+
find_package_handle_standard_args(LMDB DEFAULT_MSG LMDB_LIBRARY LMDB_INCLUDE_DIR)
13+
mark_as_advanced(LMDB_LIBRARY LMDB_INCLUDE_DIR)

include/mapcache-config.h.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#cmakedefine USE_SQLITE 1
77
#cmakedefine USE_POSTGRESQL 1
88
#cmakedefine USE_BDB 1
9+
#cmakedefine USE_LMDB 1
910
#cmakedefine USE_MEMCACHE 1
1011
#cmakedefine USE_REDIS 1
1112
#cmakedefine USE_TIFF 1

include/mapcache.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@ typedef enum {
334334
,MAPCACHE_CACHE_COUCHBASE
335335
,MAPCACHE_CACHE_RIAK
336336
,MAPCACHE_CACHE_REDIS
337+
,MAPCACHE_CACHE_LMDB
337338

338339
} mapcache_cache_type;
339340

@@ -400,6 +401,11 @@ mapcache_cache* mapcache_cache_mbtiles_create(mapcache_context *ctx);
400401
*/
401402
mapcache_cache *mapcache_cache_bdb_create(mapcache_context *ctx);
402403

404+
/**
405+
* \memberof mapcache_cache_lmdb
406+
*/
407+
mapcache_cache *mapcache_cache_lmdb_create(mapcache_context *ctx);
408+
403409
/**
404410
* \memberof mapcache_cache_memcache
405411
*/

0 commit comments

Comments
 (0)