EnyimMemcached uses the DateTime parameter to set the value after expiration to solve the problem. enyimmemcached

Source: Internet
Author: User

EnyimMemcached uses the DateTime parameter to set the value after expiration to solve the problem. enyimmemcached

Environment: win10 64-bit, memcached 1.4.4 64-bit, and EnyimMemcached 2.16.0 (ps: 2.6.2 ).

EnyimMemcached git Source Code address: https://github.com/enyim/EnyimMemcached

Cause of the incident: recently, I was trying to think about redis and Memcached cache as a public class for convenience and convenience. redis was quickly ready, memcached looks like EnyimMemcached is used a lot on the Internet (previously, Memcached was used. clientLibrary is directly filtered out because it has not been updated for many years .), start work immediately, search for and install NuGet in vs, and test the application directly,

There are three methods in it. I didn't see that much. I used the second DateTime directly. I didn't try anything else. An error was returned when Get obtained the value, the prompt is not instantiated (is there no value for instantiation?), so when we look at the value assignment, the result shows that true is returned, and the value assignment is successful, but the value is reported wrong. After a long time, it is useless to check and modify the configuration. You can use the command line to assign a value, but it is very helpless.

I accidentally used TimeSpan later, but succeeded. (I never thought it would be a parameter reason !). So we can find the source code above.

There is no difference in the Code. The MemcachedClient. GetExpiration reloads are different. Continue with the GetExpiration method.

 

The returned results are of the uint type. In the result DateTime parameter, the uint type is returned as follows: uint retval = (uint) (expiresAt. ToUniversalTime ()-UnixEpoch). TotalSeconds;

This is not the return timestamp. the TimeSpan parameter returns the number of minutes. If you cannot figure it out, the same one that returns the call is the timestamp and the other is the number of minutes.

Change it to the following minute: uint retval = (uint) (expiresAt-DateTime. Now). TotalSeconds;

OK. Compile and load the dll into your project. The value is successfully assigned by the DateTime parameter!

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.