Topic
6 replies Latest Post - ‏2013-01-04T16:39:30Z by SystemAdmin
MuraliK,Meduri
MuraliK,Meduri
50 Posts
ACCEPTED ANSWER

Pinned topic query on encrypted cache

‏2013-01-03T12:32:40Z |
Hi team
the query is on encrypted cache, while working with encrypted cache we have few operations

open
read
write
remove
close
destroy

among all these operations, which and all require the connection to Worklight server?
  • SystemAdmin
    SystemAdmin
    2327 Posts
    ACCEPTED ANSWER

    Re: query on encrypted cache

    ‏2013-01-03T13:29:06Z  in response to MuraliK,Meduri
    Hi Meduri,

    Only the "open" operation requires connection to Worklight Server.

    Others doon't need Worklight Server connection.

    Thanks,
    Chethan
  • SystemAdmin
    SystemAdmin
    2327 Posts
    ACCEPTED ANSWER

    Re: query on encrypted cache

    ‏2013-01-03T14:32:05Z  in response to MuraliK,Meduri
    I recommend you take a look at JSONStore (new in Worklight 5.0.5) if you only need to support Android and iOS. You can use it without the data sync feature if you want, just like the Encrypted Offline Cache. The API is a bit better (IMO) and it doesn't use LocalStorage to persist data which could cause you issues.

    JSONStore API Doc + Overview
    http://pic.dhe.ibm.com/infocenter/wrklight/v5r0m5/topic/com.ibm.worklight.help.doc/apiref/r_class_wl_jsonstore.html

    Module 7.9 - Overview of JSONStore
    Module 7.10 - Using JSONStore / Exercise and code sample
    Module 7.11 - JSONStore with Synchronization / Exercise and code sample
    Module 7.12 - JSONStore with Security / Exercise and code sample
    http://www.ibm.com/developerworks/mobile/worklight/getting-started/index.html
    • MuraliK,Meduri
      MuraliK,Meduri
      50 Posts
      ACCEPTED ANSWER

      Re: query on encrypted cache

      ‏2013-01-03T15:32:03Z  in response to SystemAdmin
      I have gone through the JSON store, but not much clear on that,
      1) does it too require the connection to backend always?
      2) can we use it for offline cache? or once the application is reloded, do we lose the data wahtever we saved in the JSON store?
      • SystemAdmin
        SystemAdmin
        2327 Posts
        ACCEPTED ANSWER

        Re: query on encrypted cache

        ‏2013-01-04T12:30:25Z  in response to MuraliK,Meduri
        "1) does it too require the connection to backend always?"

        Both Encrypted Cache and JSONStore require a connection to the Worklight Server -only- the first time you start them -if- you enable encryption, this is because you need a "Random String" from the server to generate the necessary keys to encrypt data. After that first time as long as you are not sending anything to the server, you can work fully offline. Also note that selecting encryption is optional in JSONStore but you don't have a choice when opening a new Encrypted Cache since that one is meant to always provide encryption. Weather or not to use encryption depends on your needs, for example if you're storing application settings like the background color the user picked on the settings page of your application you shouldn't really need it. However, if you're storing sensitive information like bank or medical information you should enable it.

        "2) can we use it for offline cache? or once the application is reloded, do we lose the data wahtever we saved in the JSON store?"

        Yes, you can use it to store data for offline use. No, you won't lose that data unless you chose to delete it or the user removes your application from their iOS or Android device.

        The code explained in this module:
        ftp://public.dhe.ibm.com/software/mobile-solutions/worklight/docs/v505/Module_07_10_-_Using_JSONStore.pdf

        and shown in this example:
        ftp://public.dhe.ibm.com/software/mobile-solutions/worklight/docs/v505/module_07_10_Using_JSONStore.zip

        is very simple and straight forward. Hence, I highly recommend you run it on your Android or iOS device. You can store data, re-open the app and it should still be there, you can also go offline and access your data as long "connectOnStartup" is set to "false" in initOptions.js.
        • MuraliK,Meduri
          MuraliK,Meduri
          50 Posts
          ACCEPTED ANSWER

          Re: query on encrypted cache

          ‏2013-01-04T16:11:21Z  in response to SystemAdmin
          Thank you so much for the explanation, looking much useful to me, and a last one, i have read some where we have to create a single json store per app, is it correct or we can create as many as we want?
          • SystemAdmin
            SystemAdmin
            2327 Posts
            ACCEPTED ANSWER

            Re: query on encrypted cache

            ‏2013-01-04T16:39:30Z  in response to MuraliK,Meduri
            "i have read some where we have to create a single json store per app, is it correct or we can create as many as we want?"

            Every Worklight Application can have just one JSONStore, but you can have many collections inside that JSONStore. For example:
            • 1 collection that holds your user settings
            • 1 collection that holds user comments
            • 1 collection that holds ... and so forth

            If you have an app that will be used by multiple users (just an example of a use case where you may want multiple JSONStores) you should probably:

            • push the data saved to the backend (see push() and pushSelected())
            • destroy the collection or the whole JSONStore (see destroy() and removeCollection())
            • create a new one for the new user (see initCollection())
            • get data for the new user (see load())

            You should submit a feature request if you want multiple JSONStores per Worklight Application:
            http://www.ibm.com/developerworks/forums/thread.jspa?threadID=461545&tstart=0

            I believe the idea behind having just a one JSONStore per Worklight App is that usually a smartphone belongs to just one user and it's unlikely that many users will login into that smartphone app. Unlike, for example, web and desktop applications.