iFun Engine API  1.0.0-b6053
Great Technology for Great Games
cross_server_storage.h
Go to the documentation of this file.
1 // Copyright (C) 2013-2020 iFunFactory Inc. All Rights Reserved.
2 //
3 // This work is confidential and proprietary to iFunFactory Inc. and
4 // must not be used, disclosed, copied, or distributed without the prior
5 // consent of iFunFactory Inc.
6 
9 #ifndef INCLUDE_FUNAPI_SERVICE_CROSS_SERVER_STORAGE_H_
10 #define INCLUDE_FUNAPI_SERVICE_CROSS_SERVER_STORAGE_H_
11 
12 #include <boost/noncopyable.hpp>
13 #include <funapi/common/json.h>
14 #include <funapi/time/wall_clock.h>
15 #include <funapi/types.h>
16 
17 
18 namespace fun {
19 
20 class FUNAPI_DLL_VISIBILITY CrossServerStorage : private boost::noncopyable {
21  public:
22  enum Result {
23  kSuccess = 0,
24  kNotExist,
25  kDuplicated,
26  kInvalidParameter,
27  kInternalError
28  };
29 
30  typedef Uuid Key;
31 
32  typedef function<void(const Key &key, Result result)> Callback;
33  typedef function<void(const Key &key,
34  const Json &data, Result result)> ReadCallback;
35 
36  // Async
37  static void Create(const Key &key, const Json &data,
38  const WallClock::Duration &expiration_time,
39  const Callback &cb);
40 
41  static void Create(const Json &data,
42  const WallClock::Duration &expiration_time,
43  const Callback &cb);
44 
45  static void Delete(const Key &key, const Callback &cb);
46 
47  static void Read(const Key &key, const ReadCallback &cb);
48 
49  static void Write(const Key &key, const Json &data,
50  const WallClock::Duration &expiration_time,
51  const Callback &cb);
52 
53  static void Refresh(const Key &key,
54  const WallClock::Duration &expiration_time,
55  const Callback &cb);
56 
57  // Sync
58  static Result CreateSync(const Key &key, const Json &data,
59  const WallClock::Duration &expiration_time);
60 
61  static Result CreateSync(const Json &data,
62  const WallClock::Duration &expiration_time,
63  Key *key);
64 
65  static Result DeleteSync(const Key &key);
66 
67  static Result ReadSync(const Key &key, Json *data);
68 
69  static Result WriteSync(const Key &key, const Json &data,
70  const WallClock::Duration &expiration_time);
71 
72  static Result RefreshSync(const Key &key,
73  const WallClock::Duration &expiration_time);
74 };
75 
76 } // namespace fun
77 
78 #endif // INCLUDE_FUNAPI_SERVICE_CROSS_SERVER_STORAGE_H_
Definition: cross_server_storage.h:20
Definition: json.h:18
boost::uuids::uuid Uuid
UUID type used throughout Funapi.
Definition: types.h:56
Definition: json.h:27