.net缓存access_token

/// <summary>
    /// 缓存access_token
    /// </summary>
    /// <param name="myCacheName">键名</param>
    /// <param name="myKey">键值</param>
    /// <param name="mySeconds">缓存秒数</param>
    /// <param name="type">值类型,如果是access_token则为1</param>
    /// <returns></returns>
    public string setToCache(string myCacheName, string myKey, int mySeconds, int type)
    {
        string cacheValue = "";

        if (Cache.Get(myCacheName) == null)
        {
            if (type == 1)
            {
                string access_token = V2.get_access_tokenV();
                myKey = access_token;                
            }
            Cache.Add(myCacheName, myKey, null, DateTime.Now.AddSeconds(mySeconds), TimeSpan.Zero, CacheItemPriority.Normal, null);
            cacheValue = myKey;
        }
        else
            cacheValue = Cache.Get(myCacheName).ToString();

        return cacheValue;

    }


在sh专题中的这个文件getcontent/preview/previewMobile1.aspx有相关存储的具体代码

你可能感兴趣的:(.net缓存access_token)