UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'cJUQK+J1ulZagt8IyaYkh9RMhOhwzXwLcRptBZcbeRY=' 
WHERE 
  key_id = '50746893a4de412490460fca87762bd267465577a00713d8858d2ac751cdf31b' 
  AND (
    token = 'cJUQK+J1ulZagt8IyaYkh9RMhOhwzXwLcRptBZcbeRY=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00032