Desktop version

Main > Knowledge Base > Knowledge Base > Knowledge base > Practical developer guide 8.3 > Lesson 14 (3:20). Optimization of posting the Services document > Theory. Understanding cache > Standard cache > Practical developer guide 8.3 > Lesson 14 (3:20). Optimization of posting the Services document > Theory. Understanding cache > Standard cache

Standard cache

If the required data is not found in the standard cache, the object data is read from the database and stored to the cache. In this case a reference to the database object serves as the unique identifier for the cache. Therefore, the data for each read object can exist in the cache in one of two forms: either all the object data, or an object presentation.

This means that if you access the cache to get an object presentation, and the cache contains data for the specified reference, that data is taken from the cache (if the entire object is in the cache, the required presentation is taken from the object data).

If the cache does not contain data for the specified reference, only the fields required to generate the object presentation are read from the database.

If you access the cache to get an object attribute, and the cache contains data for the specified reference, what comes next depends on the cache contents.

If the cache contains the entire object, the attribute value is read from the cache. If the cache contains object presentation, the presentation is deleted from the cache and then all the object data is read from the database and stored to the cache. If the cache does not contain data for the specified reference, all of the object fields are read from the database.

The read data remains in the cache until one of the following events occurs:

All the read data is kept in a sequential queue and, since the cache size is limited, the oldest data in the cache is replaced by the most recent data.

Upon subsequent calls for data that has already been read into the cache, the platform checks the elapsed time since the data entered the cache.

If the call is within 20 seconds after the data arrived, the data is considered valid. If the elapsed time is longer than 20 seconds, the platform checks that the version of the data stored in the cache matches the version in the database.

If the data versions do not match (the data in the database has been changed), the data is deleted from the cache and reread from the database. The next 20-second data validity period is counted from that point.

In addition to the listed events, read data is deleted from the cache 20 minutes after it was last read from the database.

So if you execute two operators in sequence (listing 14.43) where MaterialOrService is a reference to a catalog item, the execution of the second line takes much less time because the execution of the first line includes a database query while the execution of the second line only includes reading data from RAM (from the object cache).

Listing 14.43. Operator sequence

A = MaterialOrService.Description;
B = MaterialOrService.MaterialServiceType;

Next page: Transactional cache



© 1C LLC. All rights reserved
1C Company respects the privacy of our customers and visitors
to our Web-site.