Skip to content

Commit

Permalink
项目结构基本完成。
Browse files Browse the repository at this point in the history
  • Loading branch information
terwer committed Nov 5, 2014
1 parent 6b0ff28 commit 168e823
Show file tree
Hide file tree
Showing 243 changed files with 57,296 additions and 122 deletions.
61 changes: 61 additions & 0 deletions UCsoft.Common/CacheHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
using System;
using System.Web;
using System.Web.Caching;

namespace UCsoft.Common
{
public class CacheHelper
{
/// <summary>
/// 创建缓存项的文件依赖
/// </summary>
/// <param name="key">缓存Key</param>
/// <param name="obj">object对象</param>
/// <param name="fileName">文件绝对路径</param>
public static void Insert(string key, object obj, string fileName)
{
//创建缓存依赖项
CacheDependency dep = new CacheDependency(fileName);
//创建缓存
HttpRuntime.Cache.Insert(key, obj, dep);
}

/// <summary>
/// 创建缓存项过期
/// </summary>
/// <param name="key">缓存Key</param>
/// <param name="obj">object对象</param>
/// <param name="expires">过期时间(分钟)</param>
public static void Insert(string key, object obj, int expires)
{
HttpRuntime.Cache.Insert(key, obj, null, Cache.NoAbsoluteExpiration, new TimeSpan(0, expires, 0));
}

/// <summary>
/// 获取缓存对象
/// </summary>
/// <param name="key">缓存Key</param>
/// <returns>object对象</returns>
public static object Get(string key)
{
if (string.IsNullOrEmpty(key))
{
return null;
}
return HttpRuntime.Cache.Get(key);
}

/// <summary>
/// 获取缓存对象
/// </summary>
/// <typeparam name="T">T对象</typeparam>
/// <param name="key">缓存Key</param>
/// <returns></returns>
public static T Get<T>(string key)
{
object obj = Get(key);
return obj == null ? default(T) : (T)obj;
}

}
}
10 changes: 10 additions & 0 deletions UCsoft.Common/UCsoft.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@
<HintPath>..\packages\log4net.2.0.3\lib\net40-full\log4net.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Web" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
Expand All @@ -43,13 +45,21 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Base64.cs" />
<Compile Include="CacheHelper.cs" />
<Compile Include="DESEncrypt.cs" />
<Compile Include="LogHelper.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Utils.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\UCsoft.Entity\UCsoft.Entity.csproj">
<Project>{45e160a7-334b-4473-ad23-4753a456b6e8}</Project>
<Name>UCsoft.Entity</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
Loading

0 comments on commit 168e823

Please sign in to comment.