title: Is it possible to retrieve existing moose objects, rather than create a new one, when the same required attributes are provided?
body: <p>Suppose i have the following Moose package:</p>
  
  <pre><code>package GSM::Cell;
  use Moose;
  
  has 'ID' =&gt; (is =&gt; 'ro', required =&gt; 1);
  has [qw(BCCH NEIGHBOUR)] =&gt; (is =&gt; 'rw', default =&gt; undef);
  
  no Moose;
  __PACKAGE__-&gt;meta-&gt;make_immutable; 
  1;
  </code></pre>
  
  <p>I then create two objects and add the one as the 'NEIGHBOUR' attribute of the other:</p>
  
  <pre><code>my $a = GSM::Cell-&gt;new(ID =&gt; 20021, BCCH =&gt; 1);
  my $b = GSM::Cell-&gt;new(ID =&gt; 20022, BCCH =&gt; 2);
  $a-&gt;NEIGHBOUR($b);
  </code></pre>
  
  <p>Somewhere else, e.g. in another procedure, the BCCH attribute of $b could be updated to another value:</p>
  
  <pre><code>$b-&gt;BCCH(3);
  </code></pre>
  
  <p>Now, if i refer to</p>
  
  <pre><code> $a-&gt;NEIGHBOUR-&gt;BCCH
  </code></pre>
  
  <p>then i will still get back the initial value of the BCCH attribute instead of the updated value.</p>
  
  <p>I guess the sensible thing to do is to add a reference to $b instead of $b itself which would solve the problem:</p>
  
  <pre><code>$a-&gt;NEIGHBOUR(\$b);
  </code></pre>
  
  <p>However, i have the scenario in a web application where an object equivalent to $b (same ID) is instantiated in a multitude of methods and changes could be done in any one, making it difficult to pass around references of all your created objects.</p>
  
  <p>Ideally, when a call to </p>
  
  <pre><code>my $somevar = GSM::Cell-&gt;new(ID =&gt; 20022);
  </code></pre>
  
  <p>is made, an object should only be created if one with the same ID does not already exist.</p>
  
  <p>Is a dictionary the way to go, something like this:</p>
  
  <pre><code>$id = 20022;
  my $somevar = $already_created{$id} || GSM::Cell-&gt;new(ID =&gt; $id);
  </code></pre>
  
  <p>or are there neater solutions?</p>