UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'qVIngsrfd+9ANebIKbIHEGqGOHnCv9aEE2PT91oaG04=' 
WHERE 
  key_id = '38cd480dea41841a6fe88a32045e17618b99a30fb79693cdd1c435697311c9dc' 
  AND (
    token = 'qVIngsrfd+9ANebIKbIHEGqGOHnCv9aEE2PT91oaG04=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00024