Skip to content
This repository has been archived by the owner on Feb 6, 2020. It is now read-only.

Caching problem in the TypeQuery class #6

Open
jeromedecoster opened this issue May 30, 2010 · 1 comment
Open

Caching problem in the TypeQuery class #6

jeromedecoster opened this issue May 30, 2010 · 1 comment

Comments

@jeromedecoster
Copy link

Hello,

The TypeQuery class has a caching system to optimize speed request.
But the cache system only works in few cases.

First, add a trace to test here :
http://github.com/sammyt/fussy/blob/master/src/uk/co/ziazoo/fussy/query/TypeQuery.as#L31

if (description)
{
    trace("has already a description");
    return description;
}

If you want the description twice like this, no caching used (no trace "has already a description"):

var description:TypeDescription;
description = fussy.query().getTypeQuery().forType(Bubbles);
trace("description:", description);
description = fussy.query().getTypeQuery().forType(Bubbles);
trace("description:", description);

Perhaps you can create a QueryCache class in the query package, with a static public var:

package uk.co.ziazoo.fussy.query 
{
    import flash.utils.Dictionary;

    public class QueryCache 
    {
        public static var cache:Dictionary = new Dictionary();
    }
}

And in the TypeQuery class replace the old caching system like this:

public function forType(type:Class):TypeDescription
{
  var description:TypeDescription = QueryCache.cache[type] as TypeDescription;
  // ....
  QueryCache.cache[type] = description;
  return description;
}

Thanks !
J.

@sammyt
Copy link
Owner

sammyt commented Jun 1, 2010

Hello,

Ahh, the problem is I am creating a new TypeQuery for every type, I didnt mean to do that :)

I am in the middle of adding fine grained caching across the whole of fussy at the moment, so will ensure a fix for this make it in as well.

Thanks a lot for all your work spotting these issues!

Sammy

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants