public void get ( String key , UserDataHandler handler ) { if ( cache . containsKey ( key ) ) { try { handler . data ( key , cache . get ( key ) ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } return ; } user . sendGlobal ( "JWWF-storageGet" , "{\"key\":" + Json . escapeString ( key ) + "}" ) ; if ( waitingHandlers . containsKey ( key ) ) { waitingHandlers . get ( key ) . push ( handler ) ; } else { LinkedList < UserDataHandler > ll = new LinkedList < UserDataHandler > ( ) ; ll . push ( handler ) ; waitingHandlers . put ( key , ll ) ; } }
Gets userData string . if data exists in cache the callback is fired immediately if not async request is sent to user . If user don t have requested data empty string will arrive