Nativescript Plugin for Caching - nativescript

Is there an actively maintained nativescript plugin for data caching?
like nativescript-cache but sadly this plugin is now inactive.

you can use nativescript core module application-settings. it does exactly same as nativescript-cache plugin.
import {
getBoolean,
setBoolean,
getNumber,
setNumber,
getString,
setString,
hasKey,
remove,
clear
} from "application-settings";
Set and get boolean value and provide default value in case it is not set
setBoolean("isTurnedOn", true);
this.isTurnedOn = getBoolean("isTurnedOn", true);
Set and get string value
setString("username", "Wolfgang");
this.username = getString("username");
Set and get numeric value.
setNumber("locationX", 54.321);
this.locationX = parseFloat(getNumber("locationX").toFixed(3));
Reading values that are not set before while providing default value
// will return "No string value" if there is no value for "noSuchKey"
this.someKey = getString("noSuchKey", "No string value");
for more information you can refer nativescript docs: https://docs.nativescript.org/angular/code-samples/application-settings

Related

Retrieve only left, right, propertyName from the javers Change class

I am using the following code to retreive the changes made to a version in my API response
List<Change> versionChanges = javers.findChanges(jqlQuery.build()).groupByCommit()get(0).get()
It gave me the following
https://user-images.githubusercontent.com/10185101/122550135-f3223b00-d050-11eb-9cc8-72982808cd2e.png
But I don't want this entire data to go as my API response
I just want to isolate left, right, propertyName in my response
I am not able to find an API on Change.class that can do me so ..
How can I achieve this
Thank you
List<ChangesByCommit> changes = javers.findChanges(jqlQuery.build()).groupByCommit();
ValueChange valueChange = (ValueChange)changes.get(0).get().get(0);
String property = valueChange.getPropertyName();
Object originalValue = valueChange.getLeft();
Object newValue = valueChange.getRight();

How can I enable automatic slicing on Elasticsearch operations like UpdateByQuery or Reindex using the Nest client?

I'm using the Nest client to programmatically execute requests against an Elasticsearch index. I need to use the UpdateByQuery API to update existing data in my index. To improve performance on large data sets, the recommended approach is to use slicing. In my case I'd like to use the automatic slicing feature documented here.
I've tested this out in the Kibana dev console and it works beautifully. I'm struggling on how to set this property in code through the Nest client interface. here's a code snippet:
var request = new Nest.UpdateByQueryRequest(indexModel.Name);
request.Conflicts = Elasticsearch.Net.Conflicts.Proceed;
request.Query = filterQuery;
// TODO Need to set slices to auto but the current client doesn't allow it and the server
// rejects a value of 0
request.Slices = 0;
var elasticResult = await _elasticClient.UpdateByQueryAsync(request, cancellationToken);
The comments on that property indicate that it can be set to "auto", but it expects a long so that's not possible.
// Summary:
// The number of slices this task should be divided into. Defaults to 1, meaning
// the task isn't sliced into subtasks. Can be set to `auto`.
public long? Slices { get; set; }
Setting to 0 just throws an error on the server. Has anyone else tried doing this? Is there some other way to configure this behavior? Other APIs seem to have the same problem, like ReindexOnServerAsync.
This was a bug in the spec and an unfortunate consequence of generating this part of the client from the spec.
The spec has been fixed and the change will be reflected in a future version of the client. For now though, it can be set with the following
var request = new Nest.UpdateByQueryRequest(indexModel.Name);
request.Conflicts = Elasticsearch.Net.Conflicts.Proceed;
request.Query = filterQuery;
((IRequest)request).RequestParameters.SetQueryString("slices", "auto");
var elasticResult = await _elasticClient.UpdateByQueryAsync(request, cancellationToken);

How to set JsonSerializer default settings globally

For System.Text.Json.JsonSerializer, I have to set the options every time I serialize or deserialize or have to set attributes on every property of the object, due to lack of a way to set/change the default settings. At least I am not able to find one.
JsonSerializer.Deserialize<TypeListDTO>(
"{\"listNo\":33}",
new JsonSerializerOptions() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase});
Is there such a way available? If not, is there a workaround available?
EDIT: I am using .Net Core 3 with Endpoint Routing. But could very well not be using it at all.
Try it with AddJsonOptions(Action) in Startup.ConfigureServices:
services.AddMvc()
.AddJsonOptions( options =>
{
options.SerializerSettings.Formatting = Formatting.Indented;
options.SerializerSettings.TypeNameHandling = TypeNameHandling.Objects;
options.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
});

Dnn 8: caching module settings

I put some module settings via
var moduleController = new ModuleController();
moduleController.UpdateModuleSetting(moduleId, "key", value);
Later if I try to access the setting using
var rcModule = ModuleController.Instance.GetModuleByDefinition(PortalSettings.PortalId, "MyModule");
var value = rcModule.ModuleSettings["value"]?.ToString() ?? string.Empty;
the same value is returned (even if I resave the setting) until I clear the app cache. The value is correct after every saving settings in the database but not in the module. I also tried to add ModuleController.SynchronizeModule(moduleId); to my save settings method but it didn't help. Module and page cache both disabled.
What's wrong?
You are creating a new instance of moduleController, not getting the existing one from memory.
You can clear the cache programmatically.
DotNetNuke.Common.Utilities.DataCache.ClearModuleCache(TabId);
DotNetNuke.Common.Utilities.DataCache.ClearTabsCache(PortalId);
DotNetNuke.Common.Utilities.DataCache.ClearPortalCache(PortalId, false);
Or get the correct instance and edit the properties.
ModuleInfo moduleInfo = ModuleController.Instance.GetModule(ModuleId, TabId, false);
moduleInfo.ModuleTitle = "New Title";
ModuleController.Instance.UpdateModule(moduleInfo);

How to set set a HystrixProperty to a Feign request with spring cloud?

According to the documentation, when using Feign with Hystrix every request is wrap into a Hystrix command.
Is it possible to set Hystrix Properties to these commands? I'd like to do something like this:
#RequestMapping(commandProperties = {
#HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "30000")})
List<Team> findAll();
or:
#FeignClient(name = "teams", commandProperties = {
#HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "30000")})
For the records, I've already tried to use properties but it didn't work. These ones are working:
hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds=10000
hystrix.command.findAll.execution.timeout.enabled=false
hystrix.command.default.execution.timeout.enabled=false
But this one does not:
hystri‌​x.command.findAll.ex‌​ecution.isolation.thread.timeoutInMillis‌​econds=20000
Indeed, we can read the following comment into the HystrixCommandProperties class:
//this property name is now misleading. //TODO figure out a good way to deprecate this property name
this.executionTimeoutInMilliseconds = getProperty(propertyPrefix, key, "execution.isolation.thread.timeoutInMilliseconds", builder.getExecutionIsolationThreadTimeoutInMilliseconds(), default_executionTimeoutInMilliseconds);
EDIT: I have tried to use the feign' Request.Option but these properties doesn't seem to propagate to hystrix.
Problem solved: it was an encoding issue. I had copied/pasted a line from the documentation, but it wasn't UTF-8 encoded (although STS' display was correct).
You can also set the properties programatically like below.
ConfigurationManager.getConfigInstance()
.setProperty("hystri‌​x.command.default.ex‌​ecution.isolation.th‌​read.timeoutInMillis‌​econds", 1500);

Resources