mirror of
https://github.com/SunnyQjm/MIRCertificationManager.git
synced 2026-10-05 01:15:41 +08:00
feature: 请求回复的时候,Data包采用CachePolicy Tag,设置不需要缓存,保证每次请求都不会命中缓存
This commit is contained in:
1 parent
50e00d49a3
commit
e1b5cd70d2
2 files changed
+12
-5
No files matched your search
@@ -10,6 +10,8 @@
|
||||
#include "message/RemoveCertificateRequestMessage.h"
|
||||
#include "message/GetLifetimeRequestMessage.h"
|
||||
#include "message/ExistsCertificateRequestMessage.h"
|
||||
#include <ndn-cxx/lp/cache-policy.hpp>
|
||||
#include <ndn-cxx/lp/tags.hpp>
|
||||
|
||||
|
||||
Server::Server(std::string prefix) :
|
||||
@@ -101,6 +103,11 @@ void Server::onInterest(const InterestFilter &filter, const Interest &interest)
|
||||
std::string result = root.toStyledString();
|
||||
data.setContent((uint8_t *) result.c_str(), result.size());
|
||||
data.setFreshnessPeriod(1_ms);
|
||||
|
||||
// 设置data包不缓存
|
||||
lp::CachePolicy cachePolicy;
|
||||
cachePolicy.setPolicy(lp::CachePolicyType::NO_CACHE);
|
||||
data.setTag(make_shared<lp::CachePolicyTag>(cachePolicy));
|
||||
keyChain.sign(data);
|
||||
face.put(data);
|
||||
}
|
||||
|
||||
+5
-5
@@ -8,8 +8,8 @@
|
||||
#include <ndn-cxx/data.hpp>
|
||||
#include "utils/FileUtils.h"
|
||||
#include <boost/uuid/uuid.hpp>
|
||||
#include <boost/uuid/uuid_io.hpp>
|
||||
#include <boost/uuid/uuid_generators.hpp>
|
||||
//#include <boost/uuid/uuid_io.hpp>
|
||||
//#include <boost/uuid/uuid_generators.hpp>
|
||||
|
||||
using namespace std;
|
||||
using namespace ndn;
|
||||
@@ -22,9 +22,9 @@ int main(int argc, char **argv) {
|
||||
Interest::setDefaultCanBePrefix(true);
|
||||
string jsonStr = FileUtils::readFile2String(argv[2]);;
|
||||
ndn::Face face;
|
||||
boost::uuids::uuid a_uuid = boost::uuids::random_generator()();
|
||||
string uuid_string = boost::uuids::to_string(a_uuid);
|
||||
ndn::Interest interest("/localmanager/mircertification/" + uuid_string);
|
||||
// boost::uuids::uuid a_uuid = boost::uuids::random_generator()();
|
||||
// string uuid_string = boost::uuids::to_string(a_uuid);
|
||||
ndn::Interest interest("/localmanager/mircertification");
|
||||
interest.setMustBeFresh(true);
|
||||
interest.setApplicationParameters((uint8_t *) jsonStr.c_str(), jsonStr.size());
|
||||
face.expressInterest(interest, [=](const Interest &interest1, const Data &data) {
|
||||
|
||||
Reference in new issue
Block a user