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

Query time 0.00037