Package com.parse

Enum ParseQuery.CachePolicy

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<ParseQuery.CachePolicy>
    Enclosing class:
    ParseQuery<T extends ParseObject>

    public static enum ParseQuery.CachePolicy
    extends java.lang.Enum<ParseQuery.CachePolicy>
    CachePolicy specifies different caching policies that could be used with ParseQuery.

    This lets you show data when the user's device is offline, or when the app has just started and network requests have not yet had time to complete. Parse takes care of automatically flushing the cache when it takes up too much space.

    Note: Cache policy can only be set when Local Datastore is not enabled.

    See Also:
    ParseQuery
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
      CACHE_ELSE_NETWORK
      The query first tries to load from the cache, but if that fails, it loads results from the network.
      CACHE_ONLY
      The query only loads from the cache, ignoring the network.
      CACHE_THEN_NETWORK
      The query first loads from the cache, then loads from the network.
      IGNORE_CACHE
      The query does not load from the cache or save results to the cache.
      NETWORK_ELSE_CACHE
      The query first tries to load from the network, but if that fails, it loads results from the cache.
      NETWORK_ONLY
      The query does not load from the cache, but it will save results to the cache.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static ParseQuery.CachePolicy valueOf​(java.lang.String name)
      Returns the enum constant of this type with the specified name.
      static ParseQuery.CachePolicy[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      • Methods inherited from class java.lang.Enum

        compareTo, equals, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Enum Constant Detail

      • IGNORE_CACHE

        public static final ParseQuery.CachePolicy IGNORE_CACHE
        The query does not load from the cache or save results to the cache.

        This is the default cache policy.

      • NETWORK_ONLY

        public static final ParseQuery.CachePolicy NETWORK_ONLY
        The query does not load from the cache, but it will save results to the cache.
      • CACHE_ELSE_NETWORK

        public static final ParseQuery.CachePolicy CACHE_ELSE_NETWORK
        The query first tries to load from the cache, but if that fails, it loads results from the network.

        If there are no cached results, this causes a ParseException.CACHE_MISS.

      • NETWORK_ELSE_CACHE

        public static final ParseQuery.CachePolicy NETWORK_ELSE_CACHE
        The query first tries to load from the network, but if that fails, it loads results from the cache.

        If there are no cached results, this causes a ParseException.CACHE_MISS.

      • CACHE_THEN_NETWORK

        public static final ParseQuery.CachePolicy CACHE_THEN_NETWORK
        The query first loads from the cache, then loads from the network. The callback will be called twice - first with the cached results, then with the network results. Since it returns two results at different times, this cache policy cannot be used with synchronous or task methods.
    • Method Detail

      • values

        public static ParseQuery.CachePolicy[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (ParseQuery.CachePolicy c : ParseQuery.CachePolicy.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static ParseQuery.CachePolicy valueOf​(java.lang.String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
        java.lang.NullPointerException - if the argument is null