描 述:缓存工厂类

     /// <summary>
     ///     描 述:缓存工厂类
     /// </summary>
     public class CacheFactory
     {

         /// <summary>
         ///     定义通用的Repository
         /// </summary>
         /// <returns></returns>
         public static ICacheService Cache()
         {
             var cacheType = Config.GetValue("CacheType");
             switch (cacheType)
             {
                 case "MemoryCache":
                     return new MemoryCacheService(null);

                 case "RedisCache":
                     return new RedisCacheService();

                 default:
                     return new MemoryCacheService(null);
             }
         }
     }

描 述:缓存接口

     public interface ICacheService
     {

         /// <summary>
         /// 验证缓存项是否存在
         /// </summary>
         /// <param name="key">缓存Key</param>
         /// <returns></returns>
         bool Exists(string key);

         /// <summary>
         /// 验证缓存项是否存在(异步方式)
         /// </summary>
         /// <param name="key">缓存Key</param>
         /// <returns></returns>
         //Task<bool> ExistsAsync(string key);

         /// <summary>
         /// 添加缓存
         /// </summary>
         /// <param name="key">缓存Key</param>
         /// <param name="value">缓存Value</param>
         /// <returns></returns>
         bool Add(string key, object value);

         /// <summary>
         /// 添加缓存(异步方式)
         /// </summary>
         /// <param name="key">缓存Key</param>
         /// <param name="value">缓存Value</param>
         /// <returns></returns>
         //Task<bool> AddAsync(string key, object value);

         /// <summary>
         /// 添加缓存
         /// </summary>
         /// <param name="key">缓存Key</param>
         /// <param name="value">缓存Value</param>
         /// <param name="expiresSliding">滑动过期时长(如果在过期时间内有操作,则以当前时间点延长过期时间)</param>
         /// <param name="expiressAbsoulte">绝对过期时长</param>
         /// <returns></returns>
         bool Add(string key, object value, TimeSpan expiresSliding, TimeSpan expiressAbsoulte);

         /// <summary>
         /// 添加缓存(异步方式)
         /// </summary>
         /// <param name="key">缓存Key</param>
         /// <param name="value">缓存Value</param>
         /// <param name="expiresSliding">滑动过期时长(如果在过期时间内有操作,则以当前时间点延长过期时间)</param>
         /// <param name="expiressAbsoulte">绝对过期时长</param>
         /// <returns></returns>
         //Task<bool> AddAsync(string key, object value, TimeSpan expiresSliding, TimeSpan expiressAbsoulte);

         /// <summary>
         /// 添加缓存
         /// </summary>
         /// <param name="key">缓存Key</param>
         /// <param name="value">缓存Value</param>
         /// <param name="expiresIn">缓存时长</param>
         /// <param name="isSliding">是否滑动过期(如果在过期时间内有操作,则以当前时间点延长过期时间)</param>
         /// <returns></returns>
         bool Add(string key, object value, TimeSpan expiresIn, bool isSliding = false);

         /// <summary>
         /// 添加缓存(异步方式)
         /// </summary>
         /// <param name="key">缓存Key</param>
         /// <param name="value">缓存Value</param>
         /// <param name="expiresIn">缓存时长</param>
         /// <param name="isSliding">是否滑动过期(如果在过期时间内有操作,则以当前时间点延长过期时间)</param>
         /// <returns></returns>
         //Task<bool> AddAsync(string key, object value, TimeSpan expiresIn, bool isSliding = false);

         /// <summary>
         /// 删除缓存
         /// </summary>
         /// <param name="key">缓存Key</param>
         /// <returns></returns>
         bool Remove(string key);

         /// <summary>
         /// 删除缓存(异步方式)
         /// </summary>
         /// <param name="key">缓存Key</param>
         /// <returns></returns>
         //Task<bool> RemoveAsync(string key);

         /// <summary>
         /// 批量删除缓存
         /// </summary>
         /// <param name="key">缓存Key集合</param>
         /// <returns></returns>
         void RemoveAll(IEnumerable<string> keys);

         /// <summary>
         /// 批量删除缓存(异步方式)
         /// </summary>
         /// <param name="key">缓存Key集合</param>
         /// <returns></returns>
         //Task RemoveAllAsync(IEnumerable<string> keys);

         /// <summary>
         /// 获取缓存
         /// </summary>
         /// <param name="key">缓存Key</param>
         /// <returns></returns>
         T Get<T>(string key) where T : class;

         /// <summary>
         /// 获取缓存(异步方式)
         /// </summary>
         /// <param name="key">缓存Key</param>
         /// <returns></returns>
         //Task<T> GetAsync<T>(string key) where T : class;

         /// <summary>
         /// 获取缓存
         /// </summary>
         /// <param name="key">缓存Key</param>
         /// <returns></returns>
         object Get(string key);

         /// <summary>
         /// 获取缓存(异步方式)
         /// </summary>
         /// <param name="key">缓存Key</param>
         /// <returns></returns>
         //Task<object> GetAsync(string key);

         /// <summary>
         /// 获取缓存集合
         /// </summary>
         /// <param name="keys">缓存Key集合</param>
         /// <returns></returns>
         IDictionary<string, object> GetAll(IEnumerable<string> keys);

         /// <summary>
         /// 获取缓存集合(异步方式)
         /// </summary>
         /// <param name="keys">缓存Key集合</param>
         /// <returns></returns>
         //Task<IDictionary<string, object>> GetAllAsync(IEnumerable<string> keys);

         /// <summary>
         /// 修改缓存
         /// </summary>
         /// <param name="key">缓存Key</param>
         /// <param name="value">新的缓存Value</param>
         /// <returns></returns>
         bool Replace(string key, object value);

         /// <summary>
         /// 修改缓存(异步方式)
         /// </summary>
         /// <param name="key">缓存Key</param>
         /// <param name="value">新的缓存Value</param>
         /// <returns></returns>
         //Task<bool> ReplaceAsync(string key, object value);

         /// <summary>
         /// 修改缓存
         /// </summary>
         /// <param name="key">缓存Key</param>
         /// <param name="value">新的缓存Value</param>
         /// <param name="expiresSliding">滑动过期时长(如果在过期时间内有操作,则以当前时间点延长过期时间)</param>
         /// <param name="expiressAbsoulte">绝对过期时长</param>
         /// <returns></returns>
         bool Replace(string key, object value, TimeSpan expiresSliding, TimeSpan expiressAbsoulte);

         /// <summary>
         /// 修改缓存(异步方式)
         /// </summary>
         /// <param name="key">缓存Key</param>
         /// <param name="value">新的缓存Value</param>
         /// <param name="expiresSliding">滑动过期时长(如果在过期时间内有操作,则以当前时间点延长过期时间)</param>
         /// <param name="expiressAbsoulte">绝对过期时长</param>
         /// <returns></returns>
         //Task<bool> ReplaceAsync(string key, object value, TimeSpan expiresSliding, TimeSpan expiressAbsoulte);

         /// <summary>
         /// 修改缓存
         /// </summary>
         /// <param name="key">缓存Key</param>
         /// <param name="value">新的缓存Value</param>
         /// <param name="expiresIn">缓存时长</param>
         /// <param name="isSliding">是否滑动过期(如果在过期时间内有操作,则以当前时间点延长过期时间)</param>
         /// <returns></returns>
         bool Replace(string key, object value, TimeSpan expiresIn, bool isSliding = false);

         /// <summary>
         /// 修改缓存(异步方式)
         /// </summary>
         /// <param name="key">缓存Key</param>
         /// <param name="value">新的缓存Value</param>
         /// <param name="expiresIn">缓存时长</param>
         /// <param name="isSliding">是否滑动过期(如果在过期时间内有操作,则以当前时间点延长过期时间)</param>
         /// <returns></returns>
         //Task<bool> ReplaceAsync(string key, object value, TimeSpan expiresIn, bool isSliding = false);

     }

描 述 :MemoryCache

  public class MemoryCacheService : ICacheService
     {
         protected IMemoryCache Cache;
         public MemoryCacheService(IMemoryCache _cache)
         {
             Cache = _cache;
         }

         /// <summary>
         /// 验证缓存项是否存在
         /// </summary>
         /// <param name="key">缓存Key</param>
         /// <returns></returns>
         public bool Exists(string key)
         {
             if (key == null)
             {
                 throw new ArgumentNullException(nameof(key));
             }
             object cached;
             return Cache.TryGetValue(key, out cached);
         }
         /// <summary>
         /// 添加缓存
         /// </summary>
         /// <param name="key">缓存Key</param>
         /// <param name="value">缓存Value</param>
         /// <returns></returns>
         public bool Add(string key, object value)
         {
             if (key == null)
             {
                 throw new ArgumentNullException(nameof(key));
             }
             if (value == null)
             {
                 throw new ArgumentNullException(nameof(value));
             }
             Cache.Set(key, value);
             return Exists(key);
         }
         /// <summary>
         /// 添加缓存
         /// </summary>
         /// <param name="key">缓存Key</param>
         /// <param name="value">缓存Value</param>
         /// <param name="expiresSliding">滑动过期时长(如果在过期时间内有操作,则以当前时间点延长过期时间)</param>
         /// <param name="expiressAbsoulte">绝对过期时长</param>
         /// <returns></returns>
         public bool Add(string key, object value, TimeSpan expiresSliding, TimeSpan expiressAbsoulte)
         {
             if (key == null)
             {
                 throw new ArgumentNullException(nameof(key));
             }
             if (value == null)
             {
                 throw new ArgumentNullException(nameof(value));
             }
             Cache.Set(key, value,
                     new MemoryCacheEntryOptions()
                     .SetSlidingExpiration(expiresSliding)
                     .SetAbsoluteExpiration(expiressAbsoulte)
                     );

             return Exists(key);
         }
         /// <summary>
         /// 添加缓存
         /// </summary>
         /// <param name="key">缓存Key</param>
         /// <param name="value">缓存Value</param>
         /// <param name="expiresIn">缓存时长</param>
         /// <param name="isSliding">是否滑动过期(如果在过期时间内有操作,则以当前时间点延长过期时间)</param>
         /// <returns></returns>
         public bool Add(string key, object value, TimeSpan expiresIn, bool isSliding = false)
         {
             if (key == null)
             {
                 throw new ArgumentNullException(nameof(key));
             }
             if (value == null)
             {
                 throw new ArgumentNullException(nameof(value));
             }
             if (isSliding)
                 Cache.Set(key, value,
                     new MemoryCacheEntryOptions()
                     .SetSlidingExpiration(expiresIn)
                     );
             else
                 Cache.Set(key, value,
                 new MemoryCacheEntryOptions()
                 .SetAbsoluteExpiration(expiresIn)
                 );

             return Exists(key);
         }
         /// <summary>
         /// 删除缓存
         /// </summary>
         /// <param name="key">缓存Key</param>
         /// <returns></returns>
         public bool Remove(string key)
         {
             if (key == null)
             {
                 throw new ArgumentNullException(nameof(key));
             }
             Cache.Remove(key);

             return !Exists(key);
         }
         /// <summary>
         /// 批量删除缓存
         /// </summary>
         /// <param name="key">缓存Key集合</param>
         /// <returns></returns>
         public void RemoveAll(IEnumerable<string> keys)
         {
             if (keys == null)
             {
                 throw new ArgumentNullException(nameof(keys));
             }

             keys.ToList().ForEach(item => Cache.Remove(item));
         }

         /// <summary>
         /// 获取缓存
         /// </summary>
         /// <param name="key">缓存Key</param>
         /// <returns></returns>
         public T Get<T>(string key) where T : class
         {
             if (key == null)
             {
                 throw new ArgumentNullException(nameof(key));
             }
             return Cache.Get(key) as T;
         }
         /// <summary>
         /// 获取缓存
         /// </summary>
         /// <param name="key">缓存Key</param>
         /// <returns></returns>
         public object Get(string key)
         {
             if (key == null)
             {
                 throw new ArgumentNullException(nameof(key));
             }
             return Cache.Get(key);
         }
         /// <summary>
         /// 获取缓存集合
         /// </summary>
         /// <param name="keys">缓存Key集合</param>
         /// <returns></returns>
         public IDictionary<string, object> GetAll(IEnumerable<string> keys)
         {
             if (keys == null)
             {
                 throw new ArgumentNullException(nameof(keys));
             }

             var dict = new Dictionary<string, object>();

             keys.ToList().ForEach(item => dict.Add(item, Cache.Get(item)));

             return dict;
         }

         /// <summary>
         /// 修改缓存
         /// </summary>
         /// <param name="key">缓存Key</param>
         /// <param name="value">新的缓存Value</param>
         /// <returns></returns>
         public bool Replace(string key, object value)
         {
             if (key == null)
             {
                 throw new ArgumentNullException(nameof(key));
             }
             if (value == null)
             {
                 throw new ArgumentNullException(nameof(value));
             }
             if (Exists(key))
                 if (!Remove(key)) return false;

             return Add(key, value);

         }
         /// <summary>
         /// 修改缓存
         /// </summary>
         /// <param name="key">缓存Key</param>
         /// <param name="value">新的缓存Value</param>
         /// <param name="expiresSliding">滑动过期时长(如果在过期时间内有操作,则以当前时间点延长过期时间)</param>
         /// <param name="expiressAbsoulte">绝对过期时长</param>
         /// <returns></returns>
         public bool Replace(string key, object value, TimeSpan expiresSliding, TimeSpan expiressAbsoulte)
         {
             if (key == null)
             {
                 throw new ArgumentNullException(nameof(key));
             }
             if (value == null)
             {
                 throw new ArgumentNullException(nameof(value));
             }
             if (Exists(key))
                 if (!Remove(key)) return false;

             return Add(key, value, expiresSliding, expiressAbsoulte);
         }
         /// <summary>
         /// 修改缓存
         /// </summary>
         /// <param name="key">缓存Key</param>
         /// <param name="value">新的缓存Value</param>
         /// <param name="expiresIn">缓存时长</param>
         /// <param name="isSliding">是否滑动过期(如果在过期时间内有操作,则以当前时间点延长过期时间)</param>
         /// <returns></returns>
         public bool Replace(string key, object value, TimeSpan expiresIn, bool isSliding = false)
         {
             if (key == null)
             {
                 throw new ArgumentNullException(nameof(key));
             }
             if (value == null)
             {
                 throw new ArgumentNullException(nameof(value));
             }
             if (Exists(key))
                 if (!Remove(key)) return false;

             return Add(key, value, expiresIn, isSliding);
         }

         public void Dispose()
         {
             if (Cache != null)
                 Cache.Dispose();
             GC.SuppressFinalize(this);
         }

     }

描 述: RedisCache

  public class RedisCacheService : ICacheService
     {
         public RedisCacheService(/*RedisCacheOptions options, int database = 0*/)
         //这里可以做成依赖注入,但没打算做成通用类库,所以直接把连接信息直接写在帮助类里
         {
             RedisCacheOptions options = new RedisCacheOptions
             {
                 Configuration = "127.0.0.1:6379",
                 InstanceName = "RedisCacheService_u48H4GU583hyehdH43"
             };
             //RedisConfig.Connection;
             // RedisConfig.InstanceName;
             ; //RedisConfig.DefaultDatabase;
             _connection = ConnectionMultiplexer.Connect(options.Configuration);
             Cache = _connection.GetDatabase(database);
             _instance = options.InstanceName;
         }
         protected IDatabase Cache;
         private readonly ConnectionMultiplexer _connection;
         private readonly string _instance;

         //public RedisCacheService(RedisCacheOptions options, int database = 0)
         //{
         //    _connection = ConnectionMultiplexer.Connect(options.Configuration);
         //    Cache = _connection.GetDatabase(database);
         //    _instance = options.InstanceName;
         //}
         public string GetKeyForRedis(string key)
         {
             return _instance + key;
         }

         /// <summary>
         /// 验证缓存项是否存在
         /// </summary>
         /// <param name="key">缓存Key</param>
         /// <returns></returns>
         public bool Exists(string key)
         {
             if (key == null)
             {
                 throw new ArgumentNullException(nameof(key));
             }
             return Cache.KeyExists(GetKeyForRedis(key));
         }

         /// <summary>
         /// 添加缓存
         /// </summary>
         /// <param name="key">缓存Key</param>
         /// <param name="value">缓存Value</param>
         /// <returns></returns>
         public bool Add(string key, object value)
         {
             if (key == null)
             {
                 throw new ArgumentNullException(nameof(key));
             }
             return Cache.StringSet(GetKeyForRedis(key), Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(value)));
         }
         /// <summary>
         /// 添加缓存
         /// </summary>
         /// <param name="key">缓存Key</param>
         /// <param name="value">缓存Value</param>
         /// <param name="expiresSliding">滑动过期时长(如果在过期时间内有操作,则以当前时间点延长过期时间,Redis中无效)</param>
         /// <param name="expiressAbsoulte">绝对过期时长</param>
         /// <returns></returns>
         public bool Add(string key, object value, TimeSpan expiresSliding, TimeSpan expiressAbsoulte)
         {
             if (key == null)
             {
                 throw new ArgumentNullException(nameof(key));
             }
             return Cache.StringSet(GetKeyForRedis(key), Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(value)), expiressAbsoulte);
         }
         /// <summary>
         /// 添加缓存
         /// </summary>
         /// <param name="key">缓存Key</param>
         /// <param name="value">缓存Value</param>
         /// <param name="expiresIn">缓存时长</param>
         /// <param name="isSliding">是否滑动过期(如果在过期时间内有操作,则以当前时间点延长过期时间,Redis中无效)</param>
         /// <returns></returns>
         public bool Add(string key, object value, TimeSpan expiresIn, bool isSliding = false)
         {
             if (key == null)
             {
                 throw new ArgumentNullException(nameof(key));
             }

             return Cache.StringSet(GetKeyForRedis(key), Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(value)), expiresIn);
         }/// <summary>
          /// 删除缓存
          /// </summary>
          /// <param name="key">缓存Key</param>
          /// <returns></returns>
         public bool Remove(string key)
         {
             if (key == null)
             {
                 throw new ArgumentNullException(nameof(key));
             }
             return Cache.KeyDelete(GetKeyForRedis(key));
         }
         /// <summary>
         /// 批量删除缓存
         /// </summary>
         /// <param name="key">缓存Key集合</param>
         /// <returns></returns>
         public void RemoveAll(IEnumerable<string> keys)
         {
             if (keys == null)
             {
                 throw new ArgumentNullException(nameof(keys));
             }

             keys.ToList().ForEach(item => Remove(GetKeyForRedis(item)));
         }

         /// <summary>
         /// 获取缓存
         /// </summary>
         /// <param name="key">缓存Key</param>
         /// <returns></returns>
         public T Get<T>(string key) where T : class
         {
             if (key == null)
             {
                 throw new ArgumentNullException(nameof(key));
             }

             var value = Cache.StringGet(GetKeyForRedis(key));

             if (!value.HasValue)
             {
                 return default(T);
             }

             return JsonConvert.DeserializeObject<T>(value);
         }
         /// <summary>
         /// 获取缓存
         /// </summary>
         /// <param name="key">缓存Key</param>
         /// <returns></returns>
         public object Get(string key)
         {
             if (key == null)
             {
                 throw new ArgumentNullException(nameof(key));
             }

             var value = Cache.StringGet(GetKeyForRedis(key));

             if (!value.HasValue)
             {
                 return null;
             }

             return JsonConvert.DeserializeObject(value);
         }
         /// <summary>
         /// 获取缓存集合
         /// </summary>
         /// <param name="keys">缓存Key集合</param>
         /// <returns></returns>
         public IDictionary<string, object> GetAll(IEnumerable<string> keys)
         {
             if (keys == null)
             {
                 throw new ArgumentNullException(nameof(keys));
             }
             var dict = new Dictionary<string, object>();

             keys.ToList().ForEach(item => dict.Add(item, Get(GetKeyForRedis(item))));

             return dict;
         }
         /// <summary>
         /// 修改缓存
         /// </summary>
         /// <param name="key">缓存Key</param>
         /// <param name="value">新的缓存Value</param>
         /// <returns></returns>
         public bool Replace(string key, object value)
         {
             if (key == null)
             {
                 throw new ArgumentNullException(nameof(key));
             }

             if (Exists(key))
                 if (!Remove(key))
                     return false;

             return Add(key, value);

         }
         /// <summary>
         /// 修改缓存
         /// </summary>
         /// <param name="key">缓存Key</param>
         /// <param name="value">新的缓存Value</param>
         /// <param name="expiresSliding">滑动过期时长(如果在过期时间内有操作,则以当前时间点延长过期时间)</param>
         /// <param name="expiressAbsoulte">绝对过期时长</param>
         /// <returns></returns>
         public bool Replace(string key, object value, TimeSpan expiresSliding, TimeSpan expiressAbsoulte)
         {
             if (key == null)
             {
                 throw new ArgumentNullException(nameof(key));
             }

             if (Exists(key))
                 if (!Remove(key))
                     return false;

             return Add(key, value, expiresSliding, expiressAbsoulte);
         }
         /// <summary>
         /// 修改缓存
         /// </summary>
         /// <param name="key">缓存Key</param>
         /// <param name="value">新的缓存Value</param>
         /// <param name="expiresIn">缓存时长</param>
         /// <param name="isSliding">是否滑动过期(如果在过期时间内有操作,则以当前时间点延长过期时间)</param>
         /// <returns></returns>
         public bool Replace(string key, object value, TimeSpan expiresIn, bool isSliding = false)
         {
             if (key == null)
             {
                 throw new ArgumentNullException(nameof(key));
             }

             if (Exists(key))
                 if (!Remove(key)) return false;

             return Add(key, value, expiresIn, isSliding);
         }
         public void Dispose()
         {
             if (_connection != null)
                 _connection.Dispose();
             GC.SuppressFinalize(this);
         }

     }

C# 缓存工厂类的更多相关文章

  1. 缓存工厂之Redis缓存

    这几天没有按照计划分享技术博文,主要是去医院了,这里一想到在医院经历的种种,我真的有话要说:医院里的医务人员曾经被吹捧为美丽+和蔼+可亲的天使,在经受5天左右相互接触后不得不让感慨:遇见的有些人员在挂 ...

  2. 利用Spring.Net技术打造可切换的分布式缓存读写类

    利用Spring.Net技术打造可切换的Memcached分布式缓存读写类 Memcached是一个高性能的分布式内存对象缓存系统,因为工作在内存,读写速率比数据库高的不是一般的多,和Radis一样具 ...

  3. spring源码分析系列 (8) FactoryBean工厂类机制

    更多文章点击--spring源码分析系列 1.FactoryBean设计目的以及使用 2.FactoryBean工厂类机制运行机制分析 1.FactoryBean设计目的以及使用 FactoryBea ...

  4. Executor框架(五)Executors工厂类

    Executors 简介 Executors 是一个工厂类,其提供的是Executor.ExecutorService.ScheduledExecutorService.ThreadFactory 和 ...

  5. Executor(二)ThreadPoolExecutor、ScheduledThreadPoolExecutor 及 Executors 工厂类

    Executor(二)ThreadPoolExecutor.ScheduledThreadPoolExecutor 及 Executors 工厂类 Java 中的线程池类有两个,分别是:ThreadP ...

  6. 3.NetDh框架之缓存操作类和二次开发模式简单设计(附源码和示例代码)

    前言 NetDh框架适用于C/S.B/S的服务端框架,可用于项目开发和学习.目前包含以下四个模块 1.数据库操作层封装Dapper,支持多种数据库类型.多库实例,简单强大: 此部分具体说明可参考博客: ...

  7. 对业务类进行构造的工厂类BLLFactory

    using System; using System.Collections.Generic; using System.Text; using System.Collections; using W ...

  8. 【Java 多线程】Java线程池类ThreadPoolExecutor、ScheduledThreadPoolExecutor及Executors工厂类

    Java中的线程池类有两个,分别是:ThreadPoolExecutor和ScheduledThreadPoolExecutor,这两个类都继承自ExecutorService.利用这两个类,可以创建 ...

  9. php : 工厂类演示

    工厂类的目的: 通过类名, 动态创建该类的对象实例 <?php /* * 工厂类演示 */ class A{} class B{} // 工厂类: 有一个静态方法,通过该方法,能够获得指定类的对 ...

随机推荐

  1. "Error: ANDROID_HOME is not set and "android" command not in your PATH. You must fulfill at least one of these conditions.".

    设置环境变量 set ANDROID_HOME=C:\\android-sdk-windows set PATH=%PATH%;%ANDROID_HOME%\tools;%ANDROID_HOME%\ ...

  2. bsgs(Baby Steps Giant Steps)算法

    BSGS算法(Baby Steps Giant Steps算法,大步小步算法,北上广深算法,拔山盖世算法) 适用问题 对于式子: $$x^y=z(mod_p)$$ 已知x,z,p,p为质数: 求解一个 ...

  3. AJAX 概念 优势 发展前景 工作原理 底层技术 状态 缺点 框架

    1. 概念 Ajax asynchronous JavaScript and XML , 异步js和xml. 这种解释已经过时了, 现在ajax就是, 允许浏览器和服务器通信, 而无需刷新当前页面的技 ...

  4. Java基础之引用(String,char[],Integer)总结于牛客网的专项练习题

    1.String的引用: 下列代码执行后的结果为: public class Test { public static void main(String[] args) { StringBuffer ...

  5. 【javascript】javascript设计模式mixin模式

    概述: Mixin是JavaScript中用的最普遍的模式,几乎所有流行类库都会有Mixin的实现.任意一个对象的全部或部分属性拷贝到另一个对象上. 一 .混合对象 二 .混合类

  6. .NET AOP微型框架发布 --CleanAOP

    CleanAOP--简介 作者:立地(欧文) 邮箱:jarvin_g@126.com 导语: AOP为Aspect Oriented Programming的缩写. 意为:面向切面编程.将日志记录,性 ...

  7. Node.js 优雅地自动审核团队的代码

    Node.js® is a JavaScript runtime built on Chrome's V8 JavaScript engine. 简介 在团队开发中,无论是写前端(js,css,htm ...

  8. npm使用过程中的一些错误解决办法及npm常用命令和技巧

    node,npm在前端开发流程中提供了非常完善的自动化工具链,但是同样由于其复杂性导致有很多奇奇怪怪的问题.本文将记录使用过程中出现的一些问题及其解决方法备案. 国内由于gfw问题,导致很多国外的网站 ...

  9. HTML5离线存储之webstorage

    html5在引入webStorage之前,主要用cookies. html5的webstorage 分两种:LocalStorage 和SessionStorage,两者的差别主要在生命周期不同. 1 ...

  10. 一、python小功能记录——监听键盘事件

    1.监听键盘按键 from pynput.keyboard import Listener def press(key): print(key.char) with Listener(on_press ...