title: A complex key for guavas Cache (shifting)
body: <p>I have a point object:</p>
  
  <pre><code>  class Point {
      final int x,y;
      ...
    }
  </code></pre>
  
  <p>Because these points will be used/created all over the place in my code, I want to start using guavas cache. Unfortuinally the CacheLoader only accept one parameter.
  <a href="https://stackoverflow.com/questions/7965122/create-a-google-guava-cache-using-a-complex-key">Another question</a> here on stackoverflow use a pair object for a similar problem. But I don't like the idea to create a dummy object for every cache request.
  So I come up with my own workaround:</p>
  
  <p>Because the object is specified by the x and y, I think I can merge(shift) both values into a long, which will be my key.</p>
  
  <pre><code>void test(int x, int y) {
      Long key = (long) ((long) (x) &lt;&lt; Integer.SIZE | y);
      Point point = cache.get(key);
  }
  
  CacheLoader&lt;Long, Point&gt; loader = new CacheLoader&lt;Long, Point&gt;() {
      public Point load(Long key) throws Exception {
      final int x,y;
          // shift magic
          x = (int) (key &gt;&gt; Integer.SIZE);
          y = key.intValue();
          return new Point(x, y);
      }
  };
  </code></pre>
  
  <p><strong>I'm actually a shift noob. Will this work? Did I miss something? Is this "faster" than the pair class? That's my question!</strong></p>
  
  <p>Yes, I test the code and it works so far I can tell.</p>