UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'voFqRlEP2utRtt8Xibj9dK+RJ552+kadkFH92gfj0gs=' 
WHERE 
  key_id = '3e97e1a233006becf0e3764a4a140596b60ae81e870299e43bba90104b394f03' 
  AND (
    token = 'voFqRlEP2utRtt8Xibj9dK+RJ552+kadkFH92gfj0gs=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00034