broker integration: adapt to change in expiration_time

This commit is contained in:
Jon Siwek 2015-02-06 16:54:01 -06:00
parent ec39eee786
commit 0253f49a94
2 changed files with 14 additions and 8 deletions

@ -1 +1 @@
Subproject commit 0760c6808c1d035b7e9f484daefe8ba0a3d6ee13 Subproject commit b0d97b1fcbdcb9027bd34031c8706be0c0ab315b

View file

@ -108,20 +108,26 @@ function Store::insert%(h: opaque of Store::Handle,
auto& key = comm::opaque_field_to_data(k->AsRecordVal(), frame); auto& key = comm::opaque_field_to_data(k->AsRecordVal(), frame);
auto& val = comm::opaque_field_to_data(v->AsRecordVal(), frame); auto& val = comm::opaque_field_to_data(v->AsRecordVal(), frame);
broker::util::optional<broker::store::expiration_time> expiry; using broker::store::expiration_time;
broker::util::optional<expiration_time> expiry;
auto abs_expiry_val = e->AsRecordVal()->Lookup(0); auto abs_expiry_val = e->AsRecordVal()->Lookup(0);
auto rel_expiry_val = e->AsRecordVal()->Lookup(1);
if ( abs_expiry_val ) if ( abs_expiry_val )
{ {
auto tag = broker::store::expiration_time::tag::absolute; expiry = expiration_time(abs_expiry_val->AsTime());
expiry = broker::store::expiration_time(abs_expiry_val->AsTime(), tag); handle->store->insert(key, val, expiry);
return new Val(true, TYPE_BOOL);
} }
else if ( rel_expiry_val )
auto rel_expiry_val = e->AsRecordVal()->Lookup(1);
if ( rel_expiry_val )
{ {
auto tag = broker::store::expiration_time::tag::since_last_modification; auto ct = broker::time_point::now().value;
expiry = broker::store::expiration_time(rel_expiry_val->AsInterval(), tag); expiry = expiration_time(rel_expiry_val->AsInterval(), ct);
handle->store->insert(key, val, expiry);
return new Val(true, TYPE_BOOL);
} }
handle->store->insert(key, val, expiry); handle->store->insert(key, val, expiry);