当前位置: 首页>>代码示例>>C#>>正文


C# IDatabase.KeyExpire方法代码示例

本文整理汇总了C#中IDatabase.KeyExpire方法的典型用法代码示例。如果您正苦于以下问题:C# IDatabase.KeyExpire方法的具体用法?C# IDatabase.KeyExpire怎么用?C# IDatabase.KeyExpire使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IDatabase的用法示例。


在下文中一共展示了IDatabase.KeyExpire方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RedisSetData

 /// <summary>
 /// Enters the information about the user in Redis.
 /// </summary>
 /// <param name="db">Connecting with Redis.</param>
 /// <param name="user">Instance information about the user.</param>
 /// <param name="logging">Logging class object to create the log.</param>
 private static void RedisSetData(IDatabase db, IReadOnlyList<User> user, Logging logging)
 {
     // Serialization of User class using Json.
     var jsonValue = JsonConvert.SerializeObject(user);
     try
     {
         db.StringSet($"user:{user[0].Id}", jsonValue);
         // Life Time 10 minutes.
         db.KeyExpire($"user:{user[0].Id}", new TimeSpan(0, 10, 0));
     }
     catch (RedisException ex)
     {
         logging.ProcessingException(ex);
     }
 }
开发者ID:7BF794B0,项目名称:EntityFrameworkTestApplication,代码行数:21,代码来源:DataBase.cs

示例2: UpdateExpire

 public static void UpdateExpire(IDatabase database, string id, TimeSpan timeout)
 {
     var keys = new[] { id, GetHashKey(id) };
     foreach (var key in keys.Where(key => database.KeyExists(key)))
     {
         database.KeyExpire(key, timeout);
     }
 }
开发者ID:jango2015,项目名称:Distributed,代码行数:8,代码来源:RedisSessionStateStoreProvider.cs

示例3: BitwiseNot

        /// <summary>
        /// Perform a bitwise NOT operation on a key (containing a string value) and store the result in the destination
        /// key.
        /// </summary>
        /// <param name="database">
        /// The database where the query will be performed. This is passed so that we can reuse the same database to
        /// perform multiple bitwise operations. Doing this with the same connection will guarantee that performance
        /// is good.
        /// </param>
        /// <param name="destination">
        /// The destination key where the result should be stored.
        /// </param>
        /// <param name="key">
        /// The key where the data to be NOT'd is located.
        /// </param>
        /// <param name="expires">
        /// An expiration lifetime.
        /// </param>
        /// <returns>
        /// The size of the string stored in the destination key, that is equal to the size of the longest input string.
        /// </returns>
        /// <remarks>
        /// http://redis.io/commands/bitop
        /// </remarks>
        public static long BitwiseNot(IDatabase database, RedisKey destination, RedisKey key, TimeSpan expires)
        {
            long result = database
                .StringBitOperation(Bitwise.Not, destination, key);

            database.KeyExpire(destination, expires);

            return result;
        }
开发者ID:JesseBuesking,项目名称:BB.Caching,代码行数:33,代码来源:BitwiseAnalytics.cs

示例4: BitwiseXOr

        /// <summary>
        /// Perform a bitwise XOR operation between multiple keys (containing string values) and store the result in the
        /// destination key.
        /// </summary>
        /// <param name="database">
        /// The database where the query will be performed. This is passed so that we can reuse the same database to
        /// perform multiple bitwise operations. Doing this with the same connection will guarantee that performance
        /// is good.
        /// </param>
        /// <param name="destination">
        /// The destination key where the result should be stored.
        /// </param>
        /// <param name="keys">
        /// The keys where the data to be XOR'd are located.
        /// </param>
        /// <param name="expires">
        /// An expiration lifetime.
        /// </param>
        /// <returns>
        /// The size of the string stored in the destination key, that is equal to the size of the longest input string.
        /// </returns>
        /// <remarks>
        /// http://redis.io/commands/bitop
        /// </remarks>
        public static long BitwiseXOr(IDatabase database, RedisKey destination, RedisKey[] keys, TimeSpan expires)
        {
            long result = database
                .StringBitOperation(Bitwise.Xor, destination, keys);

            database.KeyExpire(destination, expires);

            return result;
        }
开发者ID:JesseBuesking,项目名称:BB.Caching,代码行数:33,代码来源:BitwiseAnalytics.cs

示例5: RedisSetData

        // Methods used in filling information of a modal window.

        /// <summary>
        /// Enters the information about the user in Redis.
        /// </summary>
        /// <param name="db">Connecting with Redis.</param>
        /// <param name="user">Instance information about the user.</param>
        private static void RedisSetData(IDatabase db, IReadOnlyList<User> user)
        {
            // Serialization of User class using Json.
            var jsonValue = JsonConvert.SerializeObject(user);
            try
            {
                db.StringSet($"user:{user[0].Id}", jsonValue);
                // Life Time 10 minutes.
                db.KeyExpire($"user:{user[0].Id}", new TimeSpan(0, 10, 0));
            }
            catch (RedisException ex)
            {
                var swRedisExceptionLog = new StreamWriter("RedisExceptionLog.txt", true);
                swRedisExceptionLog.WriteLine("#########################################################################################");
                swRedisExceptionLog.WriteLine($"RedisException DateTime: {DateTime.Now}\n");
                swRedisExceptionLog.WriteLine($"RedisException Data: {ex.Data}\n");
                swRedisExceptionLog.WriteLine($"RedisException HelpLink: {ex.HelpLink}\n");
                swRedisExceptionLog.WriteLine($"RedisException HResult: {ex.HResult}\n");
                swRedisExceptionLog.WriteLine($"RedisException InnerException: {ex.InnerException}\n");
                swRedisExceptionLog.WriteLine($"RedisException Message: {ex.Message}\n");
                swRedisExceptionLog.WriteLine($"RedisException Source: {ex.Source}\n");
                swRedisExceptionLog.WriteLine($"RedisException StackTrace: {ex.StackTrace}\n");
                swRedisExceptionLog.WriteLine($"RedisException TargetSite: {ex.TargetSite}\n");
                swRedisExceptionLog.Close();
            }
        }
开发者ID:7BF794B0,项目名称:EntityFrameworkTestApplication,代码行数:33,代码来源:InfoWindow.xaml.cs


注:本文中的IDatabase.KeyExpire方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。