UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'h4KbLRY/kEhfeEeeCmQLzE3wMtJYt5v9zssQnSRgS+Y=' 
WHERE 
  key_id = '5d7234e82fae787a41b8ff05dc073474d7af5be8dbb5bc45fcfe74f3bfb07ad3' 
  AND (
    token = 'h4KbLRY/kEhfeEeeCmQLzE3wMtJYt5v9zssQnSRgS+Y=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00041