2 * Copyright (c) 2015, Facebook, Inc.
5 * This source code is licensed under the BSD-style license found in the
6 * LICENSE file in the root directory of this source tree. An additional grant
7 * of patent rights can be found in the PATENTS file in the same directory.
12 #include <folly/io/async/AsyncSSLSocket.h>
16 class SSLSessionCacheManager;
19 * Interface to be implemented by providers of external session caches
21 class SSLCacheProvider {
24 * Context saved during an external cache request that is used to
25 * resume the waiting client.
28 std::string sessionId;
30 SSLSessionCacheManager* manager;
31 AsyncSSLSocket* sslSocket;
33 folly::DelayedDestruction::DestructorGuard> guard;
36 virtual ~SSLCacheProvider() {}
39 * Store a session in the external cache.
40 * @param sessionId Identifier that can be used later to fetch the
41 * session with getAsync()
42 * @param value Serialized session to store
43 * @param expiration Relative expiration time: seconds from now
44 * @return true if the storing of the session is initiated successfully
45 * (though not necessarily completed; the completion may
46 * happen either before or after this method returns), or
47 * false if the storing cannot be initiated due to an error.
49 virtual bool setAsync(const std::string& sessionId,
50 const std::string& value,
51 std::chrono::seconds expiration) = 0;
54 * Retrieve a session from the external cache. When done, call
55 * the cache manager's onGetSuccess() or onGetFailure() callback.
56 * @param sessionId Session ID to fetch
57 * @param context Data to pass back to the SSLSessionCacheManager
58 * in the completion callback
59 * @return true if the lookup of the session is initiated successfully
60 * (though not necessarily completed; the completion may
61 * happen either before or after this method returns), or
62 * false if the lookup cannot be initiated due to an error.
64 virtual bool getAsync(const std::string& sessionId,
65 CacheContext* context) = 0;