UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'sepnfp/QtN9s+2PnNIiwsym46+hTpvWN+5aIijaEDy4=' 
WHERE 
  key_id = '8b49c9bcf2b69a600067b3092b76c6259ec509c3009a498ec3f29d4b71b61798' 
  AND (
    token = 'sepnfp/QtN9s+2PnNIiwsym46+hTpvWN+5aIijaEDy4=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00042