UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = '1uO9jy7tiALP7KDU6UZ5a/AVbG7V4UOGZOrHx5fvDDE=' 
WHERE 
  key_id = 'bea27c500c55b29a5fb94ec875305463dc76dea654067acf446035186c102876' 
  AND (
    token = '1uO9jy7tiALP7KDU6UZ5a/AVbG7V4UOGZOrHx5fvDDE=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00022