title: SqlAlchemy cache with dogpile
body: <p>I have three models with inheritance and relationship and I want to cache query to this models.</p>
  
  <pre><code>class Person(Base):
      __tablename__ = 'person'
      id = Column(Integer, primary_key=True)
      name = Column(String(100), nullable=False)
      type = Column(String(50))
      __mapper_args__ = {
          'polymorphic_identity': 'object',
          'polymorphic_on': type
          }
  
  class Man(Person):
      __tablename__ = 'man'
      id = Column(Integer, ForeignKey('person.id'), primary_key=True)
      age = Column(String(100), nullable=False)
      __mapper_args__ = {'polymorphic_identity': 'man'}
  
  class Config(Base):
      __tablename__ = "config"
      id = Column(Integer, primary_key=True)
      person = Column(Integer, ForeignKey('person.id'))
      address = Column(String)
      person_ref = relationship(Person)
  </code></pre>
  
  <p>There are a lot of others models inherited from <strong>Personal</strong>.
  For example I need to get access to <strong>Man</strong> attributes through <strong>Config</strong> relationship.
  Normally I would do:</p>
  
  <pre><code>config = session.query(Config).join(Config.person_ref).filter(Person.type == 'man').first()
  print config.person_ref.age
  </code></pre>
  
  <p>How can I cache query like this with dogpile?
  I can cache query to <strong>Config</strong>, but I can't cache query to attributes of <strong>Man</strong>, emits SQL every time.
  I tried to  use with_polymorphic, but it's only works without joinedload. (don't undestand why)</p>
  
  <pre><code>config = session.query(Config).options(FromCache("default")).first()
  people = session.query(Person).options(FromCache("default")).with_polymorphic('*').get(config.person)
  </code></pre>
  
  <p>but I need joinedload to filter for types.</p>