UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'NwRFH7DmRRYcS4tmAENf1cXraV91HkcjVUkbUffkQns=' 
WHERE 
  key_id = 'df02767a734a0dd3f0d9cb51a8cedd2d9151e156a0c786832a8b3f16f73eb394' 
  AND (
    token = 'NwRFH7DmRRYcS4tmAENf1cXraV91HkcjVUkbUffkQns=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00041