We are trying to set up cache expiration in Pivotal Cloud Cache, using Gemfire. We have set up our region in PCF:
Cluster-0 gfsh>describe region --name=/CartTest
Type | Name | Value
------ | ----------------------- | ---------
Region | data-policy | PARTITION
| entry-idle-time.timeout | 60
| size | 0
| statistics-enabled | true
| entry-idle-time.action | DESTROY
When we create our Cart object, it is written to the cache (we can
see it in the size entry above).
If we access our object from our code, it does not seem to be updating the access time for the entry. For instance:
#11:00:00 - create entry
#11:00:30 - access entry
#11:01:00 - entry is gone
I would have expected the entry to still exist until 11:01:30 (I'm using ridiculously short timeouts just for testing). The idle time almost seems to be acting just like Time-To-Live. When we look at the lastAccessTime for the region using gfsh, it is not being updated.
Any idea what I'm doing wrong here?
Few things to verify.
Can you please share code showing how you store data in PCC regions ?
Is the region name correct ? Since you are using region CarTest in gfsh your #Region annotation (assuming you are using spring-data-gemfire on the client side) should also be using CarTest region name.
Easy way to put data using SDG (spring-data-gemfire) is via Spring Data Repository abstraction.
Please refer sample application here. Specifically domain class can be created like here and repository can be created like here
CORRECTION: The reason the lastAccessedTime was not being updated was because we were not getting the entry via the ID field, we were searching on two other fields in the object. When we took those two fields and created a composite key, and made it the #Id field, then the time was updated when we retrieved the object.
With partitioned Gemfire regions, any access to a secondary partition does not update the lastAccessedTime of the primary. So this won't do what we want, we'll need to add some code.
Related
I am new to Aerospike..
My namespace has multiple sets.
I am trying to set different TTLs for different sets in my aerospike dB namespace.
I do not want to use the default-ttl assigned to the namespace, instead I want to set it for each set.
my config
namespace test {
replication-factor 1
memory-size 1G
default-ttl 0
}
i referred to this link https://docs.aerospike.com/server/operations/configure, where it is stating that set specific record policies can be set.
namespace <name> { # Define namespace record policies and storage engine
storage {} # Configure persistence or lack of persistence
set {} # (Optional) Set specific record policies
}
but i am not sure what field should i use to set the ttl for each set. Say, i have two sets in this 'test' namespace named - order and name and i want their ttls to be 2hrs and 6 hours respectively.
Any help would be appreciated.
Thanks in advance
All records in aeropsike belong to a namespace, set is just a metadata, like a tag, on the record. default-ttl is the record's remaining life if the client does not specify at create or update. You cannot assign default-ttl by set in the server configuration. (There are some other set specific config parameters, for e.g. disable-eviction, enable-index that are implemented, default-ttl is not one of them.) But you can achieve the same by writing it in your client application.
For each set you can use a different write policy and in that write policy define the ttl for creating or updating records in that specific set. For e.g. in Java client, it is called WritePolicy.expiration, in seconds. In your specific case, you could do 2 hours default-ttl as server config - so orders will get that as default, for name, in client, when creating or updating records in name set, you override server default to 6 hours using WritePolicy.expiration = 3600.
I am not sure if there is another option for this so if someone could give me some advice, it would be greatly appreciated!! Keep in mind, I am a new developper so don't be too harsh with the answers.
So basically I'm developing a web application and I want to give the Admin the possibility to change the email address that will receive a copy of all sent emails (it makes sense in the case of the app). So I got this field where I temporarily have an email address, but once the client gets the app, I want them to be able to modify this email address whenever they want to.
My question is: Should I create a table in my database to store only this email address and thus be able to send a request to modify it when the Admin decides to or is there another way to do it?
Edit: Tell me if I should remove the tags or if there are any better tags for this topic!
There is often a "Admin Settings" table in many applications that allows things like this in a key-value pair sort of model.
|Setting |Value |
++++++++++++
| ccEmail |admin#yourapp.com
| othersetting| 3 |
I am converting a normal working application to multi tenant application. Currently I have my mail server configured now I am not able to figure out a way to configure multiple mail server per tenant.
I should be able to add mail server on the fly when new tenant is added.
Please help.
We can think of 2 options
Option 1
You can create a table called as TenantSettings in which you can store key-value pairs of data. The value column being straight forward data or json or any format.
In this you can store the data in the following format or we can store the data in the key-value pair like SMTPServer, SMTPPort etc..
----------------------------------------------------------------------------------------------------------------
Id TenantId Setting Value CreatedBy CreatedOn ......
----------------------------------------------------------------------------------------------------------------
1 123 SMTPConfig {SMTPServer..}
----------------------------------------------------------------------------------------------------------------
2 124 SMTPConfig {SMTPServer..}
----------------------------------------------------------------------------------------------------------------
Option 2
We can store the tenant specific settings inside the tenant specific database itself if you are having a tenant wise database so that once tenant is identified, we can load all the settings for the tenant and use wherever required.
If you can share more details on your current models, we can build a right approach.
I want to create my custom module multi store compatible. I want to get the value from my custom database table as per configuration scope. While adding the values to the database table, i have specified the scope_id and scope like as Magento does in the core_config_data table. Now how can i fetch those inserted value from the table according to the selected website on the front end.
I have the following database value snippet.
ID value scope_id scope
1 test 0 default
2 test1 4 store
3 test12 5 website
Can anybody help me in this? Thanks
It is not so easy to reuse Magento's config loading for your own needs.
What you want is to inherit your values from default -> website -> store (if not overwritten in there).
Magento converts the database config to the internal XML representation in Mage_Core_Model_Resource_Config::loadToXml and does the merging and inheritance logic in there.
The inheritance logic is all in the loadToXml() function - so you could implement something similar if you want to take the same approach and build your values for each store scope.
If you simply need to get one value for a specific scope you just have to read the database row with that store, if not found with the website the store is in, if not found the default value.
I am assuming I cannot do this using sessions but rather the DATABASE. So the user would sign in, it would set their TIMESTAMP and I display that from the database. Then it becomes deleted when the user logs out or their session is terminated. How would the code look for this?
The better question is, is my logic correct? Would this work? Does this make sense?
By default application servers store session data in temporary files on the server.
By storing session data in a database table you are able to create an interface that will show information about the users that are logged in. Apart from that, using this (database) approach is a serious advantage if you need to scale your application by adding more than one server.
One of the most popular ways to implement such a functionality is to create a session table containing your users' session data. This may look like:
create table session (
id number primary key,
data varchar(240),
timestamp date
);
The data column stores all the session data in a serialized form this is deserialized each time a user requests the data.
Serialization and deserialization may have inbuilt support depending on the platform you are using. For example, if you are using PHP, the functions session_encode and session_decode may be found useful.
You can't find out when a user logs out in PHP and the Javascript workarounds are a bit far from a stable solution.
A couple of things you need to do: Create a column in your user table called last_activity and update their last_activity to the current time whenever a user loads a page.
For a list of who's online, query the db for users with last_activity values more recent than 10 or 20 or whatever minutes ago.
To update the last_activity column use:
UPDATE users SET last_activity=CURRENT_TIMESTAMP() WHERE id=2
For a list of users online
SELECT * FROM users where last_activity >= (CURRENT_TIMESTAMP()-(60*20))