UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'II4i6JTmagdiq964Nle8uPEyN5/48LAv03L01OsFXUw=' 
WHERE 
  key_id = '4ae086560528ba380422f694aecd1ff8001695c970cd4e55f9feff42c2088257' 
  AND (
    token = 'II4i6JTmagdiq964Nle8uPEyN5/48LAv03L01OsFXUw=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00032