UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'knx3R+P0rnyYovirPzdY9TVUj41UsdVJjaLEv+M6tps=' 
WHERE 
  key_id = '18038ebbf4e3657cf19be56d9f3fd934b9c45d9f13c1a7fd2441b42cc8c9a9b8' 
  AND (
    token = 'knx3R+P0rnyYovirPzdY9TVUj41UsdVJjaLEv+M6tps=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00077