Skip to content

Commit 412ace9

Browse files
authored
Merge pull request #255 from bmanojlovic/add-redis-cache
Add redis cache (ported to new codebase)
2 parents 4033eaa + 08192ce commit 412ace9

File tree

7 files changed

+373
-0
lines changed

7 files changed

+373
-0
lines changed

CMakeLists.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ option(WITH_SQLITE "Use sqlite as a cache/dimension backend" ON)
8989
option(WITH_POSTGRESQL "Use PostgreSQL as a dimension backend" OFF)
9090
option(WITH_BERKELEY_DB "Use Berkeley DB as a cache backend" OFF)
9191
option(WITH_MEMCACHE "Use memcache as a cache backend (requires recent apr-util)" OFF)
92+
option(WITH_REDIS "Use redis as a cache backend (requires hiredis library)" OFF)
9293
option(WITH_TIFF "Use TIFFs as a cache backend" OFF)
9394
option(WITH_TIFF_WRITE_SUPPORT "Enable (experimental) support for writable TIFF cache backends" OFF)
9495
option(WITH_GEOTIFF "Allow GeoTIFF metadata creation for TIFF cache backends" OFF)
@@ -155,6 +156,17 @@ if(WITH_MEMCACHE)
155156

156157
endif(WITH_MEMCACHE)
157158

159+
if(WITH_REDIS)
160+
find_package(Redis)
161+
if(HIREDIS_FOUND)
162+
include_directories(${HIREDIS_INCLUDE_DIR})
163+
target_link_libraries(mapcache ${HIREDIS_LIBRARIES})
164+
set (USE_REDIS 1)
165+
else(HIREDIS_FOUND)
166+
report_optional_not_found(Redis)
167+
endif(HIREDIS_FOUND)
168+
endif(WITH_REDIS)
169+
158170
if(WITH_PIXMAN)
159171
find_package(Pixman)
160172
if(PIXMAN_FOUND)
@@ -321,6 +333,7 @@ status_optional_component("SQLITE" "${USE_SQLITE}" "${SQLITE_LIBRARY}")
321333
status_optional_component("POSTGRESQL" "${USE_POSTGRESQL}" "${PostgreSQL_LIBRARY}")
322334
status_optional_component("Berkeley DB" "${USE_BDB}" "${BERKELEYDB_LIBRARY}")
323335
status_optional_component("Memcache" "${USE_MEMCACHE}" "${APU_LIBRARY}")
336+
status_optional_component("Redis" "${USE_REDIS}" "${HIREDIS_LIBRARIES} ${HIREDIS_INCLUDE_DIR}")
324337
status_optional_component("TIFF" "${USE_TIFF}" "${TIFF_LIBRARY}")
325338
status_optional_component("GeoTIFF" "${USE_GEOTIFF}" "${GEOTIFF_LIBRARY}")
326339
status_optional_component("Experimental TIFF write support" "${USE_TIFF_WRITE}" "${TIFF_LIBRARY}")

cmake/FindRedis.cmake

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
IF (HIREDIS_INCLUDE_DIR AND HIREDIS_LIBRARIES)
2+
SET (HIREDIS_FOUND TRUE)
3+
ELSE(HIREDIS_INCLUDE_DIR AND HIREDIS_LIBRARIES)
4+
FIND_PATH(HIREDIS_INCLUDE_DIR hiredis/hiredis.h
5+
/usr/include/
6+
/usr/include/hiredis
7+
/usr/local/include/
8+
/usr/local/include/hiredis
9+
/opt/local/include/
10+
/opt/local/include/hiredis
11+
)
12+
13+
FIND_LIBRARY(HIREDIS_LIBRARIES NAMES hiredis libhiredis
14+
PATHS
15+
/usr/lib
16+
/usr/local/lib
17+
/opt/local/lib
18+
)
19+
20+
IF(HIREDIS_INCLUDE_DIR AND HIREDIS_LIBRARIES)
21+
SET(HIREDIS_FOUND TRUE)
22+
MESSAGE(STATUS "Found hiredis: ${HIREDIS_INCLUDE_DIR}, ${HIREDIS_LIBRARIES}")
23+
ELSE(HIREDIS_INCLUDE_DIR AND HIREDIS_LIBRARIES)
24+
SET(HIREDIS_FOUND FALSE)
25+
MESSAGE(STATUS "hiredis client library not found.")
26+
ENDIF(HIREDIS_INCLUDE_DIR AND HIREDIS_LIBRARIES)
27+
28+
MARK_AS_ADVANCED(HIREDIS_INCLUDE_DIR HIREDIS_LIBRARIES)
29+
ENDIF(HIREDIS_INCLUDE_DIR AND HIREDIS_LIBRARIES)

include/mapcache-config.h.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#cmakedefine USE_POSTGRESQL 1
88
#cmakedefine USE_BDB 1
99
#cmakedefine USE_MEMCACHE 1
10+
#cmakedefine USE_REDIS 1
1011
#cmakedefine USE_TIFF 1
1112
#cmakedefine USE_TIFF_WRITE 1
1213
#cmakedefine USE_GEOTIFF 1

include/mapcache.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,8 @@ typedef enum {
327327
,MAPCACHE_CACHE_COMPOSITE
328328
,MAPCACHE_CACHE_COUCHBASE
329329
,MAPCACHE_CACHE_RIAK
330+
,MAPCACHE_CACHE_REDIS
331+
330332
} mapcache_cache_type;
331333

332334
/** \interface mapcache_cache
@@ -408,6 +410,11 @@ mapcache_cache* mapcache_cache_tc_create(mapcache_context *ctx);
408410
*/
409411
mapcache_cache* mapcache_cache_riak_create(mapcache_context *ctx);
410412

413+
/**
414+
* \memberof mapcache_cache_redis
415+
*/
416+
mapcache_cache* mapcache_cache_redis_create(mapcache_context* ctx);
417+
411418
/** @} */
412419

413420

0 commit comments

Comments
 (0)