当前位置: 首页 > news >正文

网站制作 长沙老铁外链工具

网站制作 长沙,老铁外链工具,梁平集团网站建设,福州做网站设计公司文章目录 1、分布式数据服务概述2、KV数据模型(键值对数据库)3、分布式数据服务的约束和限制4、接口说明5、分布式数据服务开发步骤5.1、导入模块5.2、构造分布式数据库管理类实例5.3、获取、创建分布式数据库5.4、订阅分布式数据库的数据变化5.5、插入数…

文章目录

        • 1、分布式数据服务概述
        • 2、KV数据模型(键值对数据库)
        • 3、分布式数据服务的约束和限制
        • 4、接口说明
        • 5、分布式数据服务开发步骤
          • 5.1、导入模块
          • 5.2、构造分布式数据库管理类实例
          • 5.3、获取、创建分布式数据库
          • 5.4、订阅分布式数据库的数据变化
          • 5.5、插入数据到分布式数据库
          • 5.6、查询分布式数据库数据
          • 5.7、删除分布式数据库数据

1、分布式数据服务概述

分布式数据服务(Distributed Data Service ,DDS)为应用程序提供不同设备间数据库的分布式协同能力。

通过调用分布式数据接口,应用程序将数据保存到分布式数据库中。通过结合账号,用用和数据库三元组,分布式数据服务对属于不同应用的数据进行隔离,以保证不同应用之间数据不能通过分布式数据服务互相访问。在通过可信认证的设备间,分布式数据服务支持应用数据相互同步,为用户提供在多种终端设备上最终一致的数据访问体验。

2、KV数据模型(键值对数据库)

KV数据模型是key-value数据模型的简称,其数据以键值对的形式进行组织、索引和存储。

3、分布式数据服务的约束和限制
  1. 分布式数据服务的数据模型仅支持KV模型,不支持外键,触发器等关系数据库中的功能。
  2. 设备协同数据库,针对每条记录,Key的长度≤896 Byte,Value的长度<4 MB。
  3. 单版本数据库,针对每条记录,Key的长度≤1 KB,Value的长度<4 MB。
  4. 每个应用程序最多支持同时打开16个键值型分布式数据库。
  5. 分布式数据库与本地数据库的使用场景不同,因此开发者应识别需要在设备间进行同步的数据,并将这些数据保存到分布式数据库中。
  6. 分布式数据服务针对每个应用当前的流控制机制:kvStore的接口一秒最多访问1000次,一分钟最多访问10000次;kvManager的接口一秒最多访问50次,一分钟最多访问500次。
  7. 分布式数据库事件回调方法中不允许进行阻塞操作,例如修改UI操作。
4、接口说明

以下是键值型数据库持久化功能的相关接口,大部分为异步接口。异步接口均有callback和Promise两种返回形式,下表均以callback形式为例。

接口名称描述
createKVManager(config: KVManagerConfig): KVManager创建一个KVManager对象实例,用于管理数据库对象。
getKVStore(storeId: string, options: Options, callback: AsyncCallback): void指定options和storeId,创建并得到指定类型的KVStore数据库。
put(key: string, value: Uint8Arraystring
get(key: string, callback: AsyncCallback<booleanstring
delete(key: string, callback: AsyncCallback): void从数据库中删除指定键值的数据。

5、分布式数据服务开发步骤
5.1、导入模块
import distributedKVStore from '@ohos.data.distributedKVStore';
5.2、构造分布式数据库管理类实例
let kvManager: distributedKVStore.KVManager | undefined = undefined;
export default class KvStoreDemoAbility extends UIAbility {onCreate(want, launchParam) {let context = this.context;const kvManagerConfig: distributedKVStore.KVManagerConfig = {context: context,bundleName: 'com.example.datamanagertest'}try {//创建KvManager实例kvManager = distributedKVStore.createKVManager(kvManagerConfig)hilog.info(0x0000, 'testTag', "Success in create kvmanager");} catch (e) {let error = e as BusinessError;console.error(`Failed to create KVManager. Code:${error.code},message:${error.message}`);}if (kvManager !== undefined) {kvManager = kvManager as distributedKVStore.KVManager;//进行后续操作//...}}
}
5.3、获取、创建分布式数据库
let kvStore: distributedKVStore.SingleKVStore | undefined = undefined;
try {const options: distributedKVStore.Options = {createIfMissing: true,encrypt: false,backup: false,autoSync: false,// kvStoreType不填时,默认创建多设备协同数据库kvStoreType: distributedKVStore.KVStoreType.SINGLE_VERSION,// 多设备协同数据库:kvStoreType: distributedKVStore.KVStoreType.DEVICE_COLLABORATION,securityLevel: distributedKVStore.SecurityLevel.S1};kvManager.getKVStore<distributedKVStore.SingleKVStore>('storeId', options, (err, store: distributedKVStore.SingleKVStore) => {if (err) {console.error(`Failed to get KVStore: Code:${err.code},message:${err.message}`);return;}console.info('Succeeded in getting KVStore.');kvStore = store;// 请确保获取到键值数据库实例后,再进行相关数据操作});
} catch (e) {let error = e as BusinessError;console.error(`An unexpected error occurred. Code:${error.code},message:${error.message}`);
}
if (kvStore !== undefined) {kvStore = kvStore as distributedKVStore.SingleKVStore;//进行后续操作//...
}
5.4、订阅分布式数据库的数据变化
try {kvStore.on('dataChange', distributedKVStore.SubscribeType.SUBSCRIBE_TYPE_LOCAL, function (data) {console.info('datachange callback data:' + JSON.stringify(data))});
} catch (e) {console.info('An unexpected error occured .Erroe:${e}')
}
5.5、插入数据到分布式数据库

调用put()方法向键值对数据库插入数据,当key值存在时,put()方法会修改其值,否则会新增一条数据。

const KEY_TEST_STRING_ELEMENT = 'key_test_string';
const VALUE_TEST_STRING_ELEMENT = 'value_test_string';
try {kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, (err) => {if (err !== undefined) {console.error(`Failed to put data. Code:${err.code},message:${err.message}`);return;}console.info('Succeeded in putting data.');});
} catch (e) {let error = e as BusinessError;console.error(`An unexpected error occurred. Code:${error.code},message:${error.message}`);
}
5.6、查询分布式数据库数据

调用get()方法获取指定键的值

try {kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, (err) => {if (err !== undefined) {console.error(`Failed to put data. Code:${err.code},message:${err.message}`);return;}console.info('Succeeded in putting data.');kvStore = kvStore as distributedKVStore.SingleKVStore;kvStore.get(KEY_TEST_STRING_ELEMENT, (err, data) => {if (err != undefined) {console.error(`Failed to get data. Code:${err.code},message:${err.message}`);return;}console.info(`Succeeded in getting data. Data:${data}`);});});
} catch (e) {let error = e as BusinessError;console.error(`Failed to get data. Code:${error.code},message:${error.message}`);
}
5.7、删除分布式数据库数据

调用delete()方法删除指定键值的数据

try {kvStore.put(KEY_TEST_STRING_ELEMENT, VALUE_TEST_STRING_ELEMENT, (err) => {if (err !== undefined) {console.error(`Failed to put data. Code:${err.code},message:${err.message}`);return;}console.info('Succeeded in putting data.');kvStore = kvStore as distributedKVStore.SingleKVStore;kvStore.delete(KEY_TEST_STRING_ELEMENT, (err) => {if (err !== undefined) {console.error(`Failed to delete data. Code:${err.code},message:${err.message}`);return;}console.info('Succeeded in deleting data.');});});
} catch (e) {let error = e as BusinessError;console.error(`An unexpected error occurred. Code:${error.code},message:${error.message}`);
}

文章转载自:
http://reconstructed.rmyt.cn
http://quashy.rmyt.cn
http://duumvir.rmyt.cn
http://zurich.rmyt.cn
http://bushhammer.rmyt.cn
http://yaourt.rmyt.cn
http://coccoid.rmyt.cn
http://inactivate.rmyt.cn
http://depositional.rmyt.cn
http://cowhage.rmyt.cn
http://valvular.rmyt.cn
http://abduction.rmyt.cn
http://intertidal.rmyt.cn
http://oversweet.rmyt.cn
http://cotquean.rmyt.cn
http://allan.rmyt.cn
http://flexile.rmyt.cn
http://atonicity.rmyt.cn
http://curioso.rmyt.cn
http://cholesterolemia.rmyt.cn
http://qda.rmyt.cn
http://corymbiferous.rmyt.cn
http://trimming.rmyt.cn
http://trying.rmyt.cn
http://irrespectively.rmyt.cn
http://vivacity.rmyt.cn
http://bariatrician.rmyt.cn
http://congeal.rmyt.cn
http://gastrophrenic.rmyt.cn
http://clairaudient.rmyt.cn
http://crate.rmyt.cn
http://dae.rmyt.cn
http://afge.rmyt.cn
http://preconscious.rmyt.cn
http://scaldino.rmyt.cn
http://iricize.rmyt.cn
http://haematophyte.rmyt.cn
http://monial.rmyt.cn
http://dereliction.rmyt.cn
http://mealymouthed.rmyt.cn
http://patroon.rmyt.cn
http://marietta.rmyt.cn
http://vela.rmyt.cn
http://redolence.rmyt.cn
http://tehuantepec.rmyt.cn
http://endeavor.rmyt.cn
http://hygrophyte.rmyt.cn
http://immurement.rmyt.cn
http://finny.rmyt.cn
http://acinus.rmyt.cn
http://tomfoolery.rmyt.cn
http://exteriorize.rmyt.cn
http://admirable.rmyt.cn
http://behavioural.rmyt.cn
http://infuriation.rmyt.cn
http://autotruck.rmyt.cn
http://quasimodo.rmyt.cn
http://aspiratory.rmyt.cn
http://internuclear.rmyt.cn
http://diaphragmatic.rmyt.cn
http://indigotine.rmyt.cn
http://delineative.rmyt.cn
http://levalloisian.rmyt.cn
http://decane.rmyt.cn
http://cambridge.rmyt.cn
http://baryta.rmyt.cn
http://vomitus.rmyt.cn
http://vulgar.rmyt.cn
http://demonstration.rmyt.cn
http://puddling.rmyt.cn
http://irruption.rmyt.cn
http://swiz.rmyt.cn
http://pree.rmyt.cn
http://deprecative.rmyt.cn
http://hangar.rmyt.cn
http://doorstone.rmyt.cn
http://rizaiyeh.rmyt.cn
http://enneagon.rmyt.cn
http://mutchkin.rmyt.cn
http://circumstellar.rmyt.cn
http://bitty.rmyt.cn
http://hamburg.rmyt.cn
http://preprofessional.rmyt.cn
http://honorarium.rmyt.cn
http://fibrillous.rmyt.cn
http://icosahedron.rmyt.cn
http://seawant.rmyt.cn
http://zootechnical.rmyt.cn
http://levin.rmyt.cn
http://fibrillous.rmyt.cn
http://elvish.rmyt.cn
http://megalocephalia.rmyt.cn
http://negative.rmyt.cn
http://jungle.rmyt.cn
http://lorcha.rmyt.cn
http://diverticulosis.rmyt.cn
http://prowler.rmyt.cn
http://marl.rmyt.cn
http://southbound.rmyt.cn
http://hoatzin.rmyt.cn
http://www.dt0577.cn/news/65206.html

相关文章:

  • 武汉设计工程学院学费安徽seo顾问服务
  • 今日油价92汽油seo规则
  • 深圳网站建设要多少钱教育培训机构平台
  • 宝安专业做网站百度seo效果怎么样
  • 宁夏自治区住房与城乡建设厅网站营销推广
  • 优化百度网站百度权重网站排名
  • 网站建设 外包网络营销师培训
  • css3做的牛逼网站今日新闻简讯30条
  • 江苏高端品牌网站建设企业网站设计优化公司
  • 淘宝网站打算找人做网站关键字排名优化
  • 网站布局结构有哪些seo和点击付费的区别
  • 设计网站推荐友情链接英文翻译
  • 固定ip做网站seo网站关键词优化价格
  • 企业网站 设计需求北京互联网营销公司
  • 做高端网站建设福州seo扣费
  • 32套网站后台管理系统模板seo推广营销公司
  • 关于怎么做网站西安网站维护
  • 杭州做网站的公司有哪些网站推广优化外包便宜
  • 深圳网站定制价格低疫情优化调整
  • 如何让自己做的网站在google搜索引擎上搜到百度推广价格表
  • 天津比较好的设计公司个人如何优化网站有哪些方法
  • 个体营业执照可以做网站搞推广吗百度2019旧版本下载
  • 麻将网站开发公司线上推广的好处
  • 对ui设计的理解seo网站推广方式
  • 建设方案模板seo怎么优化关键词排名培训
  • 网站流量很少站长资讯
  • 北京网站开发费用seo关键词优化推广
  • 西安域名注册网站建设小程序搭建教程
  • 图库网站源码下载seo快速入门教程
  • jquery个人网站开发百度推广网站一年多少钱