jrad
jrad

Reputation: 292

ContactsApp Performance

Doing some testing on google script's ContactsApp and loading in contacts. It looks like it takes as much time to run ContactsApp.getContacts() (loading all contacts) as it does to run ContactsApp.getContact('email') (specific contact). About 14 seconds on each method for my contacts

My assumption is that both methods are calling all contacts and the 2nd only matches on email. This drags quite a bit.

Has anyone confirmed this and is there anyway to keep the loaded contacts in memory between pages (session variable?).

Upvotes: 2

Views: 364

Answers (1)

Ikai Lan
Ikai Lan

Reputation: 2240

You've got a few options for storing per-user data:

  • If it's a small amount of data, you can use User Properties
  • You can store much more data using ScriptDb, but this will be global, so you'll have to segment off user data yourself
  • If you only need the data for a short amount of time, say, between function calls, you can use the Cache Services. You'll want to use getPrivateCache()

It sounds like for your use case getPrivateCache() is your best option for user specific session-like data storage.

(Just make sure your intended use fits within the terms of service.)

Upvotes: 1

Related Questions