diff options
-rw-r--r-- | db/pdfile.h | 12 | ||||
-rw-r--r-- | db/record.cpp | 9 |
2 files changed, 20 insertions, 1 deletions
diff --git a/db/pdfile.h b/db/pdfile.h index f4198202ad6..692b5694719 100644 --- a/db/pdfile.h +++ b/db/pdfile.h @@ -220,6 +220,10 @@ namespace mongo { }; NP* np() { return (NP*) &nextOfs; } + // --------------------- + // memory cache + // --------------------- + /** * touches the data so that is in physical memory * @param entireRecrd if false, only the header and first byte is touched @@ -232,6 +236,12 @@ namespace mongo { * its not guaranteed because its possible it gets swapped out in a very unlucky windows */ bool likelyInPhysicalMemory(); + + /** + * tell the cache this Record was accessed + * @return this, for simple chaining + */ + Record* accessed(); }; /* extents are datafile regions where all the records within the region @@ -446,7 +456,7 @@ namespace mongo { return DataFileMgr::getRecord(*this); } inline BSONObj DiskLoc::obj() const { - return BSONObj(rec()); + return BSONObj(rec()->accessed()); } inline DeletedRecord* DiskLoc::drec() const { assert( _a != -1 ); diff --git a/db/record.cpp b/db/record.cpp index 9c4fcab7931..7e8656c71e6 100644 --- a/db/record.cpp +++ b/db/record.cpp @@ -205,5 +205,14 @@ namespace mongo { return false; return ProcessInfo::blockInMemory( data ); } + + Record* Record::accessed() { + const size_t page = (size_t)data >> 12; + const size_t region = page >> 6; + const size_t offset = page & 0x3f; + + ps::rolling.access( region , offset ); + return this; + } } |