2 Copyright (C) 2005 Georgia Public Library Service
3 Bill Erickson <highfalutin@gmail.com>
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
17 #include "objson/object.h"
18 #include "objson/json_parser.h"
22 osrfCache is a globally shared cache API
28 @param serverStrings An array of "ip:port" strings to use as cache servers
29 @param size The size of the serverStrings array
30 @param maxCacheSeconds The maximum amount of time an object / string may
31 be cached. Negative number means there is no limit
33 int osrfCacheInit( char* serverStrings[], int size, time_t maxCacheSeconds );
37 Puts an object into the cache
38 @param key The cache key
39 @param obj The object to cache
40 @param seconds The amount of time to cache the data, negative number means
41 to cache up to 'maxCacheSeconds' as set by osrfCacheInit()
42 @return 0 on success, -1 on error
44 int osrfCachePutObject( char* key, const jsonObject* obj, time_t seconds );
47 Puts a string into the cache
48 @param key The cache key
49 @param value The string to cache
50 @param seconds The amount of time to cache the data, negative number means
51 to cache up to 'maxCacheSeconds' as set by osrfCacheInit()
52 @return 0 on success, -1 on error
54 int osrfCachePutString( char* key, const char* value, time_t seconds);
57 Grabs an object from the cache.
58 @param key The cache key
59 @return The object (which must be freed) if it exists, otherwise returns NULL
61 jsonObject* osrfCacheGetObject( char* key, ... );
64 Grabs a string from the cache.
65 @param key The cache key
66 @return The string (which must be freed) if it exists, otherwise returns NULL
68 char* osrfCacheGetString( char* key, ... );
71 Removes the item with the given key from the cache.
72 @return 0 on success, -1 on error.
74 int osrfCacheRemove( char* key, ... );