dotnetcore / SmartSql

SmartSql = MyBatis in C# + .NET Core+ Cache(Memory | Redis) + R/W Splitting + PropertyChangedTrack +Dynamic Repository + InvokeSync + Diagnostics
https://smartsql.net/
Apache License 2.0
1.1k stars 222 forks source link

add support Cache-Annotations for IRepository #80

Closed Ahoo-Wang closed 5 years ago

Ahoo-Wang commented 5 years ago
    [Cache("DateCache", "Lru", FlushInterval = 6000)]
    [Cache("LruCache", "Lru", FlushInterval = 6000)]
    [Cache("UserCache", "Fifo", FlushOnExecutes = new[] {"UpdateUserName"})]
    public interface IUsedCacheRepository
    {
        [ResultCache("DateCache", Key = "GetNow")]
        [Statement(Sql = "Select Now();")]
        DateTime GetNow();

        [ResultCache("LruCache", Key = "GetId:$id")]
        [Statement(Sql = "Select @id;")]
        int GetId(long id);

        [ResultCache("UserCache", Key = "GetUserById:$id")]
        [Statement(Sql = "select * from T_User where id=@id;")]
        User GetUserById(long id);

        [Statement(Sql = "update T_User set UserName=@userName where id=@id;")]
        int UpdateUserName(long id, string userName);
    }
Ahoo-Wang commented 5 years ago

ref -> https://github.com/dotnetcore/SmartSql/releases/tag/v4.1.5