UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'S02z0WunOtQ51I7sE9M1smcq2ZJND4EWhvmxM1OrynY=' 
WHERE 
  key_id = '1c47bcf1184423df93e5fb249109636d19932155f970682e9de5c98c4a81d01e' 
  AND (
    token = 'S02z0WunOtQ51I7sE9M1smcq2ZJND4EWhvmxM1OrynY=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00036