Skip to content

Storage

setStorageSync

Base library support from 1.3.9, iOS version 2.1.23, Android version 2.1.38

setStorageSync(string key, any data)

ft.setStorage The synchronous version of

parameter

  • string key Specified in the local cache key
  • any data The content that needs to be stored. Supports only native types, Date, and the ability to passJSON.stringifySerialized object

sample code

javascript
ft.setStorage({
  key: 'key',
  data: 'value'
})

try {
  ft.setStorageSync('key', 'value')
} catch (e) { }

setStorage

Base library support from 1.3.9, iOS version 2.1.23, Android version 2.1.38

setStorage(Object object)

To store data in the local cache key In. Will overwrite the original key The corresponding content. Data is always available unless the user actively deletes it or the system cleans it for storage reasons. single key The maximum length of data allowed to be stored is 1 MB, all data storage capped at 10MB

parameter

Object object

attributetypeDefault valuesRequiredIntroductions
keystringyesSpecified in the local cache key
dataanyyesThe content that needs to be stored. Supports only native types, Date, and the ability to passJSON.stringifySerialized object.
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback function at the end of an interface call (both successful and unsuccessful calls are executed)

sample code

javascript
ft.setStorage({
  key: 'key',
  data: 'value'
})

try {
  ft.setStorageSync('key', 'value')
} catch (e) { }

removeStorageSync

Base library support from 1.3.9, iOS version 2.1.23, Android version 2.1.38

removeStorageSync(string key)

ft.removeStorage The synchronous version of

sample code

javascript
ft.removeStorage({
  key: 'key',
  success(res) {
    console.log(res)
  }
})

try {
  ft.removeStorageSync('key')
} catch (e) {
  // Do something when catch error
}

removeStorage

Base library support from 1.3.9, iOS version 2.1.23, Android version 2.1.38

removeStorage(Object object)

Removes the specified item from the local cache key。 Cache related policies to view storage

parameter

Object object

attributetypeDefault valuesRequiredIntroductions
keystringyesSpecified in the local cache key
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback function at the end of an interface call (both successful and unsuccessful calls are executed)

sample code

javascript
ft.removeStorage({
  key: 'key',
  success(res) {
    console.log(res)
  }
})

try {
  ft.removeStorageSync('key')
} catch (e) {
  // Do something when catch error
}

getStorageSync

Base library support from 1.3.9, iOS version 2.1.23, Android version 2.1.38

getStorageSync(string key)

ft.getStorage The synchronous version of

parameter

string key Specified in the local cache key

Return value

any data key corresponds to the content

sample code

javascript
ft.getStorage({
  key: 'key',
  success(res) {
    console.log(res.data)
  }
})

try {
  const value = ft.getStorageSync('key')
  if (value) {
    // Do something with return value
  }
} catch (e) {
  // Do something when catch error
}

getStorageInfoSync

Base library support from 1.3.9, iOS version 2.1.23, Android version 2.1.38

getStorageInfoSync(Object object)

ft.getStorageInfo The synchronous version of

Return value

Object object

attributetypeIntroductions
keysArray.<string>Current storage All of the key
currentSizenumberThe current amount of space occupied, unit KB
limitSizenumberLimited space size, unit KB

sample code

javascript
ft.getStorageInfoSync({
  success(res) {
    console.log(res.keys)
    console.log(res.currentSize)
    console.log(res.limitSize)
  }
})

try {
  const res = ft.getStorageInfoSync()
  console.log(res.keys)
  console.log(res.currentSize)
  console.log(res.limitSize)
} catch (e) {
  // Do something when catch error
}

getStorageInfo

Base library support from 1.3.9, iOS version 2.1.23, Android version 2.1.38

getStorageInfo(Object object)

Gets information about the current storage asynchronously. Cache related policies to view storage

parameter

Object object

attributetypeDefault valuesRequiredIntroductions
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback function at the end of an interface call (both successful and unsuccessful calls are executed)

object.success callback

parameter

Object res

attributetypeIntroductions
keysArray.<string>Current storage All of the key
currentSizenumberThe current amount of space occupied, unit KB
limitSizenumberLimited space size, unit KB

sample code

javascript
ft.getStorageInfo({
  success(res) {
    console.log(res.keys)
    console.log(res.currentSize)
    console.log(res.limitSize)
  }
})

try {
  const res = ft.getStorageInfoSync()
  console.log(res.keys)
  console.log(res.currentSize)
  console.log(res.limitSize)
} catch (e) {
  // Do something when catch error
}

getStorage

Base library support from 1.3.9, iOS version 2.1.23, Android version 2.1.38

getStorage(Object object)

Gets the specified object asynchronously from the local cache key The content of. Cache related policies to view storage

parameter

Object object

attributetypeDefault valuesRequiredIntroductions
keystringyesSpecified in the local cache key
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback function at the end of an interface call (both successful and unsuccessful calls are executed)

object.success callback

parameter

Object res

attributetypeIntroductions
dataanyKey corresponds to the content

sample code

javascript
ft.getStorage({
  key: 'key',
  success(res) {
    console.log(res.data)
  }
})

try {
  const value = ft.getStorageSync('key')
  if (value) {
    // Do something with return value
  }
} catch (e) {
  // Do something when catch error
}

clearStorageSync

Base library support from 1.3.9, iOS version 2.1.23, Android version 2.1.38

clearStorageSync(Object object)

ft.clearStorage The synchronous version of

sample code

javascript
ft.clearStorage()

try {
  ft.clearStorageSync()
} catch (e) {
  // Do something when catch error
}

clearStorage

Base library support from 1.3.9, iOS version 2.1.23, Android version 2.1.38

clearStorage(Object object)

Clean the local data cache. Cache related policies to view storage

parameter

Object object

attributetypeDefault valuesRequiredIntroductions
successfunctionnoInterface calls the successful callback function
failfunctionnoInterface calls failed callback functions
completefunctionnoCallback function at the end of an interface call (both successful and unsuccessful calls are executed)

sample code

javascript
ft.clearStorage()

try {
  ft.clearStorageSync()
} catch (e) {
  // Do something when catch error
}