2 * Copyright 2001-2007 Internet2
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 * @file xmltooling/util/ReplayCache.h
20 * Helper class on top of StorageService for detecting message replay.
23 #if !defined(__xmltooling_replay_h__) && !defined(XMLTOOLING_LITE)
24 #define __xmltooling_replay_h__
26 #include <xmltooling/util/StorageService.h>
28 namespace xmltooling {
31 * Helper class on top of StorageService for detecting message replay.
33 class XMLTOOL_API ReplayCache
35 MAKE_NONCOPYABLE(ReplayCache);
39 * Creates a replay cache on top of a particular StorageService.
41 * The lifetime of the StorageService <strong>MUST</strong> be longer than
42 * the lifetime of the ReplayCache.
44 * @param storage pointer to a StorageService, or NULL to keep cache in memory
46 ReplayCache(StorageService* storage=NULL);
48 virtual ~ReplayCache();
51 * Returns true iff the check value is not found in the cache, and stores it.
53 * @param context a context label to subdivide the cache
54 * @param s value to check
55 * @param expires time for disposal of value from cache
57 virtual bool check(const char* context, const char* s, time_t expires);
60 * Returns true iff the check value is not found in the cache, and stores it.
62 * @param context a context label to subdivide the cache
63 * @param s value to check
64 * @param expires time for disposal of value from cache
66 bool check(const char* context, const XMLCh* s, time_t expires) {
67 auto_ptr_char temp(s);
68 return check(context, temp.get(), expires);
73 StorageService* m_storage;
77 #endif /* __xmltooling_replay_h__ */