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"
23 osrfCache is a globally shared cache API
29 @param serverStrings An array of "ip:port" strings to use as cache servers
30 @param size The size of the serverStrings array
31 @param maxCacheSeconds The maximum amount of time an object / string may
32 be cached. Negative number means there is no limit
34 int osrfCacheInit( char* serverStrings[], int size, time_t maxCacheSeconds );
38 Puts an object into the cache
39 @param key The cache key
40 @param obj The object to cache
41 @param seconds The amount of time to cache the data, negative number means
42 to cache up to 'maxCacheSeconds' as set by osrfCacheInit()
43 @return 0 on success, -1 on error
45 int osrfCachePutObject( char* key, const jsonObject* obj, time_t seconds );
48 Puts a string into the cache
49 @param key The cache key
50 @param value The string to cache
51 @param seconds The amount of time to cache the data, negative number means
52 to cache up to 'maxCacheSeconds' as set by osrfCacheInit()
53 @return 0 on success, -1 on error
55 int osrfCachePutString( char* key, const char* value, time_t seconds);
58 Grabs an object from the cache.
59 @param key The cache key
60 @return The object (which must be freed) if it exists, otherwise returns NULL
62 jsonObject* osrfCacheGetObject( char* key, ... );
65 Grabs a string from the cache.
66 @param key The cache key
67 @return The string (which must be freed) if it exists, otherwise returns NULL
69 char* osrfCacheGetString( char* key, ... );
72 Removes the item with the given key from the cache.
73 @return 0 on success, -1 on error.
75 int osrfCacheRemove( char* key, ... );
78 * Sets the expire time to 'seconds' for the given key
80 int osrfCacheSetExpire( time_t seconds, char* key, ... );