@@ -222,9 +222,9 @@ class AsyncCacheStressor : public Stressor {
222
222
ThroughputStats& stats,
223
223
const Request* req,
224
224
folly::EventBase* evb,
225
- const std::string* key) {
225
+ const std::string_view key) {
226
226
++stats.get ;
227
- auto lock = chainedItemAcquireSharedLock (* key);
227
+ auto lock = chainedItemAcquireSharedLock (key);
228
228
229
229
if (ticker_) {
230
230
ticker_->updateTimeStamp (req->timestamp );
@@ -233,8 +233,7 @@ class AsyncCacheStressor : public Stressor {
233
233
// add a distribution over sequences of requests/access patterns
234
234
// e.g. get-no-set and set-no-get
235
235
236
- auto onReadyFn = [&, req, key = *key,
237
- l = std::move (lock)](auto hdl) mutable {
236
+ auto onReadyFn = [&, req, key, l = std::move (lock)](auto hdl) mutable {
238
237
auto result = OpResultType::kGetMiss ;
239
238
240
239
if (hdl == nullptr ) {
@@ -247,7 +246,7 @@ class AsyncCacheStressor : public Stressor {
247
246
// appropriate here)
248
247
l.unlock ();
249
248
auto xlock = chainedItemAcquireUniqueLock (key);
250
- setKey (pid, stats, & key, *(req->sizeBegin ), req->ttlSecs ,
249
+ setKey (pid, stats, key, *(req->sizeBegin ), req->ttlSecs ,
251
250
req->admFeatureMap );
252
251
}
253
252
} else {
@@ -260,8 +259,8 @@ class AsyncCacheStressor : public Stressor {
260
259
}
261
260
};
262
261
263
- cache_->recordAccess (* key);
264
- auto sf = cache_->asyncFind (* key);
262
+ cache_->recordAccess (key);
263
+ auto sf = cache_->asyncFind (key);
265
264
if (sf.isReady ()) {
266
265
// If the handle is ready, call onReadyFn directly to process the handle
267
266
onReadyFn (std::move (sf).value ());
@@ -283,9 +282,9 @@ class AsyncCacheStressor : public Stressor {
283
282
ThroughputStats& stats,
284
283
const Request* req,
285
284
folly::EventBase* evb,
286
- const std::string* key) {
285
+ const std::string_view key) {
287
286
++stats.get ;
288
- auto lock = chainedItemAcquireUniqueLock (* key);
287
+ auto lock = chainedItemAcquireUniqueLock (key);
289
288
290
289
// This was moved outside the lambda, as otherwise gcc-8.x crashes with an
291
290
// internal compiler error here (suspected regression in folly).
@@ -297,7 +296,7 @@ class AsyncCacheStressor : public Stressor {
297
296
++stats.getMiss ;
298
297
299
298
++stats.set ;
300
- wHdl = cache_->allocate (pid, * key, *(req->sizeBegin ), req->ttlSecs );
299
+ wHdl = cache_->allocate (pid, key, *(req->sizeBegin ), req->ttlSecs );
301
300
if (!wHdl) {
302
301
++stats.setFailure ;
303
302
return ;
@@ -327,7 +326,7 @@ class AsyncCacheStressor : public Stressor {
327
326
};
328
327
329
328
// Always use asyncFind as findToWrite is sync when using HybridCache
330
- auto sf = cache_->asyncFind (* key);
329
+ auto sf = cache_->asyncFind (key);
331
330
if (sf.isReady ()) {
332
331
onReadyFn (std::move (sf).value ());
333
332
return ;
@@ -345,10 +344,10 @@ class AsyncCacheStressor : public Stressor {
345
344
void asyncUpdate (ThroughputStats& stats,
346
345
const Request* req,
347
346
folly::EventBase* evb,
348
- const std::string* key) {
347
+ const std::string_view key) {
349
348
++stats.get ;
350
349
++stats.update ;
351
- auto lock = chainedItemAcquireUniqueLock (* key);
350
+ auto lock = chainedItemAcquireUniqueLock (key);
352
351
if (ticker_) {
353
352
ticker_->updateTimeStamp (req->timestamp );
354
353
}
@@ -363,7 +362,7 @@ class AsyncCacheStressor : public Stressor {
363
362
cache_->updateItemRecordVersion (wHdl);
364
363
};
365
364
366
- auto sf = cache_->asyncFind (* key);
365
+ auto sf = cache_->asyncFind (key);
367
366
if (sf.isReady ()) {
368
367
onReadyFn (std::move (sf).value ());
369
368
return ;
@@ -457,18 +456,18 @@ class AsyncCacheStressor : public Stressor {
457
456
const auto pid = static_cast <PoolId>(opPoolDist (gen));
458
457
const Request& req (getReq (pid, gen, lastRequestId));
459
458
OpType op = req.getOp ();
460
- const std::string* key = &( req.key ) ;
461
- std::string oneHitKey;
459
+ std::string_view key = req.key ;
460
+ std::string_view oneHitKey;
462
461
if (op == OpType::kLoneGet || op == OpType::kLoneSet ) {
463
462
oneHitKey = Request::getUniqueKey ();
464
- key = & oneHitKey;
463
+ key = oneHitKey;
465
464
}
466
465
467
466
OpResultType result (OpResultType::kNop );
468
467
switch (op) {
469
468
case OpType::kLoneSet :
470
469
case OpType::kSet : {
471
- auto lock = chainedItemAcquireUniqueLock (* key);
470
+ auto lock = chainedItemAcquireUniqueLock (key);
472
471
result = setKey (pid, stats, key, *(req.sizeBegin ), req.ttlSecs ,
473
472
req.admFeatureMap );
474
473
@@ -481,8 +480,8 @@ class AsyncCacheStressor : public Stressor {
481
480
}
482
481
case OpType::kDel : {
483
482
++stats.del ;
484
- auto lock = chainedItemAcquireUniqueLock (* key);
485
- auto res = cache_->remove (* key);
483
+ auto lock = chainedItemAcquireUniqueLock (key);
484
+ auto res = cache_->remove (key);
486
485
if (res == CacheT::RemoveRes::kNotFoundInRam ) {
487
486
++stats.delNotFound ;
488
487
}
@@ -532,7 +531,7 @@ class AsyncCacheStressor : public Stressor {
532
531
OpResultType setKey (
533
532
PoolId pid,
534
533
ThroughputStats& stats,
535
- const std::string* key,
534
+ const std::string_view key,
536
535
size_t size,
537
536
uint32_t ttlSecs,
538
537
const std::unordered_map<std::string, std::string>& featureMap) {
@@ -543,7 +542,7 @@ class AsyncCacheStressor : public Stressor {
543
542
}
544
543
545
544
++stats.set ;
546
- auto it = cache_->allocate (pid, * key, size, ttlSecs);
545
+ auto it = cache_->allocate (pid, key, size, ttlSecs);
547
546
if (it == nullptr ) {
548
547
++stats.setFailure ;
549
548
return OpResultType::kSetFailure ;
0 commit comments