Windows Azure에서 호스팅되는 일련의 WCF 웹 서비스가 있고 appfabric 캐싱을 구현하려고합니다.Azure Appfabric Caching + WCF Webservices
저는 웹 서비스의 무국적 특성과 datacachefactory 및 datacache 객체의 값 비싼 초기화를 피할 필요가 있습니다.
이 시작하기 좋은 장소가 될 듯 나는이 싱글에 내 datacachefactory을 감쌌다.....
Imports Microsoft.ApplicationServer.Caching
Public Class Cache
Private Shared _DataCacheFactory As DataCacheFactory
Private Shared _DataCache As Microsoft.ApplicationServer.Caching.DataCache
Private Sub New()
End Sub
Shared ReadOnly Property DataCacheFactory As DataCacheFactory
Get
If IsNothing(_DataCacheFactory) Then
Dim localTimeout As New TimeSpan(0, 10, 0)
Dim localCacheConfig As New DataCacheLocalCacheProperties(10000, localTimeout, DataCacheLocalCacheInvalidationPolicy.TimeoutBased)
Dim factoryConfig As New DataCacheFactoryConfiguration()
factoryConfig.LocalCacheProperties = localCacheConfig
_DataCacheFactory = New DataCacheFactory(factoryConfig)
End If
Return _DataCacheFactory
End Get
End Property
Shared ReadOnly Property DataCache As Microsoft.ApplicationServer.Caching.DataCache
Get
If IsNothing(_DataCache) Then
_DataCache = DataCacheFactory.GetDefaultCache
End If
Return _DataCache
End Get
End Property
End Class
하지만 그것을 사용하려고하면,이 범위를 벗어나려고하고있는 것 같다 azure 인스턴스 당 단 한번 반복되는 대신에 반복적으로 재생성됩니다. 내가 올바르게 이해한다면, 이것은 기본적으로 ..... wcf 웹 서비스에 전역 변수를 저장하여 범위를 벗어나지 않게 할 수 있습니다.
왜 downvote? 이것은 합리적인 질문처럼 보입니다. –
WCF 인스턴스는 어떻게 호스팅됩니까? 웹 역할이 있거나 작업자 역할에서 자체 호스팅되는 IIS? –
IIS 웹 역할에서 호스팅됩니다. –