PouchDb Local database size - ionic2

We are developing an app in ionic3 which use PouchDB and CouchDB. We would like to launch on mid February but we are worry if the database grow too much I make run out of memory in device.
To test we'd like to insert thousands records and check database size.. here we have the problem. We can't find out how get local db size.
I was diving in PouchDB documentation and I only found how to get info about remote database size but not local. I think remote size needs not to be equal than local. Anyone have an idea?
Thanks

I found a partial solution, it is partial because it only works in android, chrome and firefox but not in ios and safari. I get used and available storage with this
calculaEspacio(){
let nav: any = navigator;
nav.storage.estimate().then((obj)=>{
this.usado=Math.round(((obj.usage/1048576)*100))/100;
this.total = Math.round(((obj.quota/1048576)*100))/100;
})}
Anyone know equivalent for webkit?

Example
npm install pouchdb pouchdb-size
//index.js
var PouchDB = require('pouchdb');
PouchDB.plugin(require('pouchdb-size'));
var db = new PouchDB('test');
db.installSizeWrapper();
db.info().then(function (resp) {
//resp will contain disk_size
})
pouchdb-size https://github.com/pouchdb/pouchdb-size
Build Status Dependency Status devDependency Status
Adds disk_size to info()'s output for your *down backed PouchDB's.
Tested with leveldown, sqldown, jsondown, locket and medeadown. When it can't determine the database size, it falls back to the default info() output.

Full informations here
If you're using Ionic 3, I guess you can use the SQLite Plugin to have unlimited data

Related

why is django app creating huge keys in redis

I am running django app (wagtail) in kubernetes cluster along with redis. These two pieces are connected by django-redis. This is how my backend configuration look
{
"BACKEND":"django_redis.cache.RedisCache",
"LOCATION":"redis://redis-service:6379/0",
"OPTIONS":{
"CLIENT_CLASS":"django_redis.client.DefaultClient",
"CONNECTION_POOL_KWARGS":{
"max_connections":1000
}
}
}
This works just fine. I can see keys getting created in redis and app is also blazing fast thanks to redis.
Now real issue is every once in a while app slows down for some time. Upong investigation we found out the real issue is a key of size ~90 MB is created in redis. to process this key app takes some time and slows down.
To put a comparison other keys are less than 1 MB always just 1 key gets randomly created on one type of endpoint but not always.
I tried to check the contents of the key after unpickling and it is normal amounts of data just like other keys. but running
redis-cli --bigkeys
gives output something like this
Biggest string found '":1:views.decorators.cache.cache_page.XXXXXXX.GET.9b37c27c4fc5f19eb59d8e8ba7e1999e.83bf0aec533965b875782854d37402b7.en-us.UTC"' has 90709641 bytes
has someone seen similar issue? Anyway to debug the root cause.
django-redis version "==4.12.1"
wagtail version "==2.11.1"
django version "==3.1.3"

AppsFlyer: Is there way to find if user reinstalls the app

I am trying to find if the users current app install if the first or if its a reinstall. Is there any way to determine this using iOS SDK?
You can make use of the getAppsFlyerUID API and compare the ID's you are getting.
Swift:
let appsflyerId = AppsFlyerTracker.shared().getAppsFlyerUID()
Objective-C:
NSString *appsflyerId = [AppsFlyerTracker sharedTracker].getAppsFlyerUID;
For every new install, you should see a new AppsFlyer ID.
For this to work in between app reinstalls, you'll have to keep the "old" AppsFlyer ID in a persistent data storage like KeyChain or an internal BI system - so you can compare (or check if a previous ID exists).

Sitecore Commerce Connect > Refreshing a Cache via code

I am trying to update the commerce catalog from external source. After the incremental update I need to have fresh data in Sitecore tree(data provider should return correct data instead of old(cached) ones). However, if I go to Sitecore right after the data import I can see only the old data till I click on "Refresh Catalog Cache" button in Sitecore Commerce menu.
I found the same info in the documentation for Sitecore Commerce Connect, however I can't find any example how to clean cache via code.
I found several types in "Sitecore.Commerce.Connect.CommerceServer.Caching" namespace. For example, CacheRefresh static class. It has RefreshCatalogCaches method which needs ICommerceServerContextManager contextManager as input parameter. If I create contextManager just using constructor new CommerceServerContextManager() and passing it to the method - it doesn't work(at least I still need to clean cache manually).
I would appreciate any advise/suggestion.
Thank you in advance.
You should do in your code same that happens on "Refresh Catalog Cache" button click:
CacheRefreshEvent eventX = new CacheRefreshEvent("catalogcache", "master", = ID.Null);
EventManager.QueueEvent<CacheRefreshEvent>(eventX, true, true);
For more details, look on Sitecore.Commerce.Connect.CommerceServer.Caching.RefreshCache, Sitecore.Commerce.Connect.CommerceServer implementation via reflector.

Unable to determine if iCloud is enabled on my device

This is my code:
- (IBAction)aBackupSetup:(UIButton *)sender {
// check to see if this device is iCloud enabled; display message if not
NSURL *ubiq = [[NSFileManager defaultManager] URLForUbiquityContainerIdentifier:nil];
if (ubiq) {
NSLog(#"AppDelegate: iCloud access!");
} else {
NSLog(#"AppDelegate: No iCloud access (either you are using simulator or, if you are on your phone, you should check settings");
}
I'm trying to determine if iCloud is enabled on the device (iPad). When I run this code by tapping on a UIButton in my app, it logs "No iCloud access...". I have seen this code all over SO and the internet - why is it not working on my device? (iCloud IS enabled on the iPad).
Reasons why you'd always get a nil result here:
iCloud is not actually enabled (though you say it was, so that's not it this time)
iCloud is enabled on the device but "Documents & Data" is not. "iCloud" covers a lot of services, so just being enabled in general isn't enough. Without Documents & Data, apps can't save data in iCloud.
Your provisioning profile either doesn't include iCloud or is broken in such a way that it prevents iCloud from working. Provisioning profile requirements include:
You must enable iCloud for the app ID in the "Certificates, Identifiers & Profiles" section of the iOS dev center.
The app ID can't include a wildcard (*), it has to be a complete ID.
Your app ID in Xcode must match the one from the previous step exactly.
You must generate a provisioning profile after doing the above so that you have a profile that reflects the iCloud entitlement. If you had an old provisioning profile for this app that didn't include iCloud, you must delete it and replace it with a new one.
If you get any of these steps wrong, checking the URL will simply return nil. There's no error condition, but since iCloud access is not enabled there's no URL either.
For iOS 6 and up you're better off checking for iCloud availability using
id ubiquityToken = [[NSFileManager defaultManager] ubiquityIdentityToken];
That's a lot faster. Looking up the URL can involve network connections, but this method returns immediately. You'll still need the URL to read/write data in iCloud, but if you just want to check availability, use this method.

How to programmatically dump Launch Services database?

How can I programmatically dump/query Launch Services database in MacOS (i.e. analog of command lsregister -dump)?
EDIT: I want to get set of associations UTI -> Bundle_IDs. Using LSCopyAllRoleHandlersForContentType - does not always work, here a similar trouble, therefore concluded that the best working method - parsing the output of "lsregister -dump", but the location of lsregister changes from version to version.