Storage Engine API
namespace_uuid_cache.h
Go to the documentation of this file.
1 
29 #pragma once
30 
31 #include "mongo/base/disallow_copying.h"
33 #include "mongo/db/operation_context.h"
34 #include "mongo/util/string_map.h"
35 #include "mongo/util/uuid.h"
36 
37 namespace mongo {
38 
39 extern bool debugCollectionUUIDs;
40 
45 using CollectionUUID = UUID;
46 class Database;
47 
50 
51 public:
52  static const OperationContext::Decoration<NamespaceUUIDCache> get;
53  NamespaceUUIDCache() = default;
54 
62  void ensureNamespaceInCache(const NamespaceString& nss, CollectionUUID uuid);
63 
69  void evictNamespace(const NamespaceString& nss);
70 
74  void evictNamespacesInDatabase(StringData dbname);
75 
79  void verifyNotCached(const NamespaceString& nss, CollectionUUID uuid) {
80  auto it = _cache.find(nss.ns());
81  invariant(it == _cache.end() || it->second != uuid);
82  }
83 
84 private:
85  using CollectionUUIDMap = StringMap<CollectionUUID>;
87 };
88 } // namespace mongo
Definition: namespace_uuid_cache.h:48
void evictNamespace(const NamespaceString &nss)
This function removes the entry for nss.ns() from the namespace UUID cache.
Definition: namespace_uuid_cache.cpp:67
Copyright (C) 2014 MongoDB Inc.
Definition: bson_collection_catalog_entry.cpp:38
void verifyNotCached(const NamespaceString &nss, CollectionUUID uuid)
For testing only: verify that &#39;nss&#39; is not cached.
Definition: namespace_uuid_cache.h:79
MONGO_DISALLOW_COPYING(NamespaceUUIDCache)
UUID CollectionUUID
A CollectionUUID is a 128-bit unique identifier, per RFC 4122, v4.
Definition: collection_options.h:53
bool debugCollectionUUIDs
StringMap< CollectionUUID > CollectionUUIDMap
Definition: namespace_uuid_cache.h:85
IndexSet::const_iterator it
Definition: ephemeral_for_test_btree_impl.cpp:458
Collection *const OperationContext *const const StringData OptionalCollectionUUID uuid
Definition: collection_impl.cpp:80
void ensureNamespaceInCache(const NamespaceString &nss, CollectionUUID uuid)
This function adds the pair nss.ns(), uuid to the namespace UUID cache if it does not yet exist...
Definition: namespace_uuid_cache.cpp:50
CollectionUUIDMap _cache
Definition: namespace_uuid_cache.h:86
void evictNamespacesInDatabase(StringData dbname)
Same as above, but for all registered namespaces in the given dbname.
Definition: namespace_uuid_cache.cpp:75