Get List Of Keys In Cache - Use Default Name Region?

Jan 14, 2011

I am trying to convert a solution using EntLib into using AppFabric caching. By help of a few extension methods this is a fairly pain-free process.

Extension methods I use:
public static bool Contains(this DataCache dataCache, string key)
{
return dataCache.Get(key) != null;
}
public static object GetData(this DataCache dataCache, string key)
{
return dataCache.Get(key);
}

But there are two features of EntLib I find difficult to convert. Namely "Count" (counting number of keys in cache) and "Flush" (removing all data from cache). Both could be solved if I could iterate the keys in cache. There is a method called ClearRegion(string region), but that required me to specify a region name on all Get/Put/Add-methods I use, which would require some manual error-prone work.

Is there any way to get a list of keys in cache?
Is there a default region name I can use?
How can I flush the cache when I haven't used a region name?

View 1 Replies


Similar Messages:

C# - Maximum Length Of Cache Keys In HttpRuntime.Cache Object?

Feb 24, 2010

We are using HttpRuntime.Cache API in an ASP.NET to cache data retrieved from a database.

For this particular application, our database queries feature a LOT of parameters, so our cache keys look something like this:

table=table1;param1=somevalue1;param2=somevalue2;param3=somevalue3;param4=somevalue4;param5=somevalue5;param6=somevalue6... etc...

we have so many parameters that the cache key is several hundred characters long. is there a limit to the length of these cache keys? Internally, it is using a dictionary, so theoretically the lookup time should be constant. However, I wonder if we have potential to run into some performance/memory problem.

View 1 Replies

Architecture :: Cache The Full List Of Objects In Http Cache On The Service Tier And Page In Memory?

Feb 25, 2011

We have a wfc layer that wraps the business classes and database access and use a client that lives on the database layer. Amongst our group we are attempting to form standards. Some want to have the client call the web method and pass the page they are requesting and the page size. Pass that to the database and then page in SQL Server use RowNum.Some want to cache the full list of objects in http cache on the service tier and page in memory. They concern here is memory use on the server.

Which would be best for a medium number of users with potentially large number of records to manage (say 30K) Is it better to cache them all in memory and work from there or page at the database as the application scales?

View 1 Replies

Access :: Getting List Of Foreign Keys?

Feb 28, 2011

I am using Access 2003 Database and I need to retrieve list of a table's foreign keys and tables they are related to in C#. I used GetSchema() function of OleDbConnection as well as OdbcConnection classes. But It just returns the name of key among few other details.

OdbcConnection con = new OdbcConnection(conStr);

View 6 Replies

Forms Data Controls :: Deleting A Record On A File With Multiple Keys / Access The Rest Of The Keys?

Feb 8, 2010

I have a DataGrid that I need to be able to use to delete records form a file

[Code]....

[Code]....

I use

((TextBox)GridMenuOptions.Rows[e.RowIndex].Cells[1].Controls[0]).Text;

To access the data in the Grid for updating, but it doesn't work for deleting

I can use

string id = GridMenuOptions.DataKeys[e.RowIndex].Value.ToString();

but that only returns the first key.

How do I access the rest of the keys?

View 9 Replies

Configuration :: Web.config AppSettings - Keys Referencing Other Keys?

Dec 7, 2010

My current project has many peripheral systems and many different environments (testing, integration, development etc). As expected, we're using .config files to dynamically manage everything.

Instead of updating each relavant key when deploying to an environment, I was hoping there was a way to change 1 key only. Such as:

<add key="Environment" value="Development"/>

<add key="WebServiceLocation" value="http://<<Environment>>/text.asmx"/>

I've done some searching and haven't come up with an elegant solution. I'm aware that .config files can make use of system variables, but this seems like a bit of a high wire act.

View 2 Replies

Caching - What Is The Default Serialization Used By The HttpRuntime.Cache

Jan 29, 2010

what the default serialization used by the ASP.net HttpRuntime.Cache is? Is it Binary, XML, something else?

I am populating a generic List with multiple objects of the same custom type. The custom type is a POCO, there is nothing special about it. All of its properties are public with { get; set; }, it is public, it has no inheritance, it has no interfaces. In fact it is much less complicated than many other objects which we are caching which work without issue. I have tried adding the [Serializable] attribute to the custom class and it has no effect.

I add the list to the cache with a unique key. The list has been verified as populated before it is inserted into the cache, the objects in the list have been verified as populated as well. But when the list is pulled back out of the cache it is an empty list (NOT NULL), it simply has no items in it. This means that the list is being added to the cache and is retrievable but for some reason the cache is having issues serializing the objects in the list.

I just find this freaky weird since I have another list of custom objects which are much more complicated (consisting of Inheritance, Interfaces, and also containing Properties which are generic lists of other complex objects) and the caching of those lists work without issue.

Both the working and non-working list are being managed in C# classes outside of the ASP.net user controls which consume the cached data. Both of these cache handling classes call the exact same Cache Manager class singleton instance which wraps the HttpRuntime.Cache to provide typed methods for pull and pushing objects into the cache.

Here is the class

[code]....

View 2 Replies

C# - .resx Serialization / List Of All Valid Keys For A Given *.resx File

May 14, 2010

I'm contributing on an I18N project and there's a call to serialize our *.resx files as JSON objects (for whatever reason).

What I'm wondering is:

Is there a way to get a list of all of the valid keys for a given *.resx file so that we could use HttpContext.GetGlobalResourceObject to grab the tokens?
If that won't work, has anyone come up with a clever solution that does?

View 1 Replies

Cache A List Of Data C#?

Feb 27, 2011

I want to implement caching of a list pulled from the db. I've had a look at this:

How can I cache objects in ASP.NET MVC?

I have this in my code:

var addresses = repository.GetAllAddresses();//returns IQueryable<string>

using the answer in the question above how can i cache this?, I have created the class CacheExtensions, but not sure where to go from there.

View 1 Replies

State Management :: How To Add A List To The Cache

Nov 19, 2010

I want to add a list to the cache and I would like it to stay there as long as posible.

Is there a way adding something to the cache permanently?

how do i set the exiry date of a cached object?

View 6 Replies

Caching - How To Cache A List Of Objects

Jan 23, 2010

I have a List of objects in an asp.net page. when the page loads in the browser for the first time, I fetch data from the database, create objects with those data and populate the list. All these are done inside the page load event handler. Now when the page is posted back to the page, the previous list is gone, since the variables were all freed.

How can I cache that List, so that when this page is posted back, all my objects are available?

View 5 Replies

Way To Create A List - Simple Cache Implementation

Mar 16, 2010

I need to build up a List<object> and cache the list and be able to append to it. I also need to be able to blow it away easily and recreate it. What is a simple way to accomplish this?

View 2 Replies

State Management :: Cast From Cache To Generic List Throws An Exception

Mar 17, 2011

In Asp.net application. i cache a Linq to Xml result to a Cache object. when i cast the cache object back to generic list. i get the following exception.

[A]System.Collections.Generic.List`1[CarRentalAddress] cannot be cast to [B]System.Collections.Generic.List`1[CarRentalAddress]. Type A originates from 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' in the context 'LoadNeither' at location 'C:WINDOWSassemblyGAC_32mscorlib2.0.0.0__b77a5c561934e089mscorlib.dll'. Type B originates from 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' in the context 'LoadNeither' at location 'C:WINDOWSassemblyGAC_32mscorlib2.0.0.0__b77a5c561934e089mscorlib.dll'.

My code looks like this.

if (!Page.IsPostBack) { if (Cache["xml"] == null) { DataSet ds = new DataSet(); ds.ReadXml(HttpContext.Current.Server.MapPath("~/CarRentalAddress.xml")); var grid = (from d in ds.Tables[0].AsEnumerable() orderby d.Field<string>("City") where d.Field<string>("Enabled") == "1" select new CarRentalAddress { City = d.Field<string>("City"), HotelName = d.Field<string>("HotelName"), Address = d.Field<string>("Address"), EmailID1 = d.Field<string>("EmailID1"), EmailID2 = d.Field<string>("EmailID2") }).ToList(); Cache["xml"] = grid; totalrows = grid.Count().ToString(); grdAddress.DataSource = grid; grdAddress.DataBind(); } else { //Exception is thrown by this line var grid = (List<CarRentalAddress>)Cache["xml"]; totalrows = grid.Count().ToString(); grdAddress.DataSource = grid; grdAddress.DataBind(); } }

View 4 Replies

Add Or Update Or Delete Cached Data - Remove The Entire List From The Cache

Jan 17, 2010

U are caching a list of items, then Add or update or delete method called. Approach 1)

A- Do the data change at the database. If success do B, C
B- Remove the entire list from the Cache.
C- Re-Cache the list on first read.

Approach 2)

A- Do the data change at the database, If success do B
B- Do the same change at the cached items, and save more time.

Approach(2) probably will cause nasty difficult to spot bugs, because the data come from BLL and placed directly into cache, One can't assume no bugs will happen at the sproc, I am not worry about database runtime errors, runtime errors will show up, but I am worry about invalid data, or miss calculation. Can I proceed with approach (2) with caution? Is there a "best practice" principle which suggest not doing approach(2)?

View 2 Replies

State Management :: Cache System.Collection.Generic.List Object?

Aug 22, 2010

I need to cache System.Collection.Generic.List object with expiration time

var Root = from feed in feedhotel.Descendants(ota + "HotelContent")
where (feed.Attribute("HotelCode") != null)
select new xmlhotel()
{
};
return Root.ToList();

Is it possible to cache Root.ToList() for some time....

View 1 Replies

MVC :: Drop Down List MVC Default Value?

Mar 12, 2010

i have a drop down list like so:

<%= Html.DropDownList("CampaignId", null, "-- Select Campaign --", new { @class = "dropdown" })%>

I want to be able to have '0' (zero) for CampaignId for "--Select Campaign--" selection. Is this possible to specify 0(zero) for "--Select Campaign-- option instead of ""?

View 2 Replies

MVC :: How To Set The Default Selected Value For A Dropdown List

Aug 31, 2010

how i can set the default selected value for a dropdown list. My actual code is:

[Code]....

the GetAvatars() function return a List<MyObject> that contains the avatars informations such as filename and file url. I don't know if i this is correct, anyway i want to display a selectbox that shows the list of the avatars in a folder with a predefinited avatar selected and i would like to show an image near the selectbox with the current selected avatar. How can i do it? I don't find any way to set the default value

View 4 Replies

Web Forms :: Default Value Of Dropdown List?

Sep 21, 2010

I have a DropDownList that is bound to sql datasource . How can i set its default value to Null and change its value to one of its items programmicaly.

View 3 Replies

What Is #region And What Does It Do

Mar 15, 2010

What is #region, and what does it do?

View 2 Replies

Web Forms :: Add A A First Default Item To A Drop Down List

Feb 9, 2011

I fill a the drop down list with a SQL select query, but i want to add a first default item, something like "- Select an option -" or "All"

What im trying to do is make a dynamic SQL query, something like this:

SELECT * FROM table1 WHERE (value1 = ? AND value2 = ? AND value3 = ? )........ (or "like" instead of "=")

You are gonna have to select those arguments from 3 drop down lists, but i wanna have a default value on the top of the drop down list options and send a "*" as value if this option its selected, so the filter doesn't consider that value

View 7 Replies

C# - Dropdown List Selected Item Always Set To Default Value

Jan 17, 2011

I wish to pass values of the selected items into a database and however noticed that the selected item is not what is sent into the database you can see in the snap shot below. during run time the following value is recorded. Where did it all go wrong with the dropdown lists selected item? Counting on your intelligence.

View 3 Replies

How To Select Default Value In Dropdown List Using JQuery

Feb 12, 2011

I want to select "Algeria" as default selected value in drop down list.I am fetching countrylist from database using handler ( LoadCountryList.ashx ) in JSON data format and binding it to dropdownlist on aspx page using Jquery's $.getJSON precedure given below

[code]...

View 3 Replies

MVC :: Generic List With Default Value As Method Parameter?

Jun 1, 2010

In one of the methods I'm using in my MVC app, there's a param that accepts a list collection of strings. If I have a string parameter, I can give it a default value of an empty string, but I cannot seem to give the list collection a default value of a new, empty list collection. I get the error that's beginning to seriously grate on my nerves about requiring a compile-time constant. getting the generic list to work with a default empty set?

View 5 Replies

DropDownList / HTML Select List Default Selection?

Jul 18, 2010

For my ASP.NET page, in the code behind I load various items/options into a DropDownList but I do not set a default by assigning SelectedIndex. I notice for the postback SelectedIndex is set to 0, even if I never set focus to or changed the value in the DropDownList.

If not otherwise specified in the code behind or markup, will a default value of 0 be used for the SelectedIndex in a postback with a DropDownList? If yes, is this part of the HTML standard for selection lists, or is this just the way it is implemented for ASP.NET?

View 1 Replies

AJAX :: How To Set Default Value For Drop Down List Filled With Cascading

Aug 29, 2010

I've this problem, how can I set the default value for drop down list filled with cascading.

I can't catch the event that came after cascading to set the default value and I can't call any control in this function:

"AjaxControlToolkit.CascadingDropDownNameValue[]"

I've passed the Drop down list as a session and the default value in session

When I call the session of "Drop Down List" the session value Is NULL in this function:

"AjaxControlToolkit.CascadingDropDownNameValue[]"

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved