jstests/core/plan_cache_list_plans.js
// and the time a plan was cached should not be larger than an hour.
and the time a plan was cached should not be larger than an hour.
and the time a plan was cached should not be larger than an hour .
function checkTimeOfCreation(query, sort, projection, date) {
    const keyHash = getPlanCacheKeyFromShape(
        {query: query, projection: projection, sort: sort, collection: coll, db: db});
    const res =
        coll.aggregate([{$planCacheStats: {}}, {$match: {planCacheKey: keyHash}}]).toArray();
    assert.eq(1, res.length, res);
    const cacheEntry = res[0];
    assert(cacheEntry.hasOwnProperty('timeOfCreation'), cacheEntry);
    let kMillisecondsPerHour = 1000 * 60 * 60;
    assert.lte(
        Math.abs(date - cacheEntry.timeOfCreation.getTime()), kMillisecondsPerHour, cacheEntry);
}
function checkTimeOfCreation ( query , sort , projection , date ) { const keyHash = getPlanCacheKeyFromShape ( { query : query , projection : projection , sort : sort , collection : coll , db : db } ) ; const res = coll . aggregate ( [ { $planCacheStats : { } } , { $match : { planCacheKey : keyHash } } ] ) . toArray ( ) ; assert . eq ( 1 , res . length , res ) ; const cacheEntry = res [ 0 ] ; assert ( cacheEntry . hasOwnProperty ( 'timeOfCreation' ) , cacheEntry ) ; let kMillisecondsPerHour = 1000 * 60 * 60 ; assert . lte ( Math . abs ( date - cacheEntry . timeOfCreation . getTime ( ) ) , kMillisecondsPerHour , cacheEntry ) ; }
and the time a plan was cached should not be larger than an hour.
and the time a plan was cached should not be larger than an hour .
// We expect exactly one matching cache entry.