UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'HAYrPw/dX5r40tFXGMVdSt+74Kmx2Cr87qYIT3ZDAb8=' 
WHERE 
  key_id = '394cb2968c219f79e3959d5cd5aacb762a2397cd5272f4825cc62277ab44c581' 
  AND (
    token = 'HAYrPw/dX5r40tFXGMVdSt+74Kmx2Cr87qYIT3ZDAb8=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00030