Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redis Distributed Cache DistributedCacheEntryOptions #1

Open
JarvisPos opened this issue Feb 26, 2022 · 1 comment
Open

Redis Distributed Cache DistributedCacheEntryOptions #1

JarvisPos opened this issue Feb 26, 2022 · 1 comment

Comments

@JarvisPos
Copy link

Merhaba Yusuf Bey,

Makaleniz için öncelikle teşekkür ederim. Kurmuş olduğunuz yapıda DistributedCacheEntryOptions parametlerini hangi aşamada eklemeliyiz yardımcı olurmusunuz?

İyi Çalışmalar

@yusufyilmazfr
Copy link
Owner

Merhaba,

Öncelikle ilginiz için ben teşekkür ediyorum. :)

İlk olarak şöyle başlamak istiyorum, Devnot'ta yazdığım yazı StackExchange.Redis ile ilgili. Eğer bu kısımda bir işlem yapmak istiyorsanız cevabı direkt buradan da görebilirsiniz. StringSet (Tabii StringSet burada sadece bir örnek, diğer veri yapılarına göre olan metotlara da göz atılabilir.)

Şayet Microsoft.Extensions.Caching.Distributed paketi için soruyorsanız da DistributedCacheEntryOptions sınıfını ilgili cache'i Redis'e atarken kullanabilirsiniz.

İlgili sınıfa ait kaynak kodlara da bakıldığında zaten cache'e ait süre bilgileri yer alıyor. Bu da eklenirken belirtilen ifadeler.

// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;

namespace Microsoft.Extensions.Caching.Distributed
{
    /// <summary>
    /// Provides the cache options for an entry in <see cref="IDistributedCache"/>.
    /// </summary>
    public class DistributedCacheEntryOptions
    {
        private DateTimeOffset? _absoluteExpiration;
        private TimeSpan? _absoluteExpirationRelativeToNow;
        private TimeSpan? _slidingExpiration;
    }
    // ....
}
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System.Threading;
using System.Threading.Tasks;

namespace Microsoft.Extensions.Caching.Distributed
{
    /// <summary>
    /// Represents a distributed cache of serialized values.
    /// </summary>
    public interface IDistributedCache
    {
        /// <summary>
        /// Sets a value with the given key.
        /// </summary>
        /// <param name="key">A string identifying the requested value.</param>
        /// <param name="value">The value to set in the cache.</param>
        /// <param name="options">The cache options for the value.</param>
        void Set(string key, byte[] value, DistributedCacheEntryOptions options);

        /// <summary>
        /// Sets the value with the given key.
        /// </summary>
        /// <param name="key">A string identifying the requested value.</param>
        /// <param name="value">The value to set in the cache.</param>
        /// <param name="options">The cache options for the value.</param>
        /// <param name="token">Optional. The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
        /// <returns>The <see cref="Task"/> that represents the asynchronous operation.</returns>
        Task SetAsync(string key, byte[] value, DistributedCacheEntryOptions options, CancellationToken token = default(CancellationToken));
    // ...
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants