UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'tsoFv8lo9sWo5YJnzdVtxUqK52D47vUKTgn5rusAX2c=' 
WHERE 
  key_id = '121ce46665aae115e92e5a3e79e0574776dd985a50661bc65da1d72a112ec526' 
  AND (
    token = 'tsoFv8lo9sWo5YJnzdVtxUqK52D47vUKTgn5rusAX2c=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00034