Tuesday, 27 November 2012

Difference between sliding expiration and absolute expiration

http://weblogs.asp.net/jalpeshpvadgama/archive/2010/10/26/difference-between-sliding-expiration-and-absolute-expiration.aspx


Difference between sliding expiration and absolute expiration
ASP.net cache is great feature through which we can increase the performance of the our web application via reducing server round trips to database. We can cache any serializable data into the cache. There are so many ways to cache data but one of the simplest way to cache data like insert data into cache object. Here we must need to validate cache if any data is changed and there are so many ways from where we can set dependency to validate the cache like files,SQL Cache Dependency etc. We also can validate cache or expire via setting time to duration to its object. Like after the defined time our cache will expire and then it will again put new fresh data into the cache. This is called as time base expiration. We can put this kind of expiration via two way.
  1. Absolute Expiration
  2. Sliding Expiration
Absolute Expiration: Absolute expiration means It will expire cache after some time period set at the time of activating cache. This will be absolute expiration whether cache will be used or not It will expire the cache. This type of expiration used to cache data which are not frequently changing.
Sliding Expiration: Sliding expiration means It will expire cache after time period at the time of activating cache if any request is not made during this time period. This type of expiration is useful when there are so many data to cache. So It will put those items in the cache which are frequently used in the application. So it will not going to use unnecessary memory.
Here is the example how we can set the sliding expiration and absolute expiration.
?
1
2
3
4
5
6
7
string cacheData = "The data to be cached";
//Absolute Expiration
Cache.Insert("AbsoluteCacheKey", cacheData, null,
DateTime.Now.AddMinutes(1), System.Web.Caching.Cache.NoSlidingExpiration);
//Sliding Expiration
Cache.Insert("SlidingExpiration", cacheData, null,
System.Web.Caching.Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(1));
In above example I have created the a string to be cache that can be any serialized data. In the absolute expiration you can see that it will expires after one minute whether its accessed or not. While in sliding expiration it will expire cache if cache is not accessed within specified time like one minute.

Friday, 2 November 2012

Session vs Cache

The key difference is session is per user, while cache will be for application scoped items.

 


Another difference is:

Items put into a session will stay there, until the session ends.
Items in the cache can expire (will be removed from cache) after a specified amount of time. And also there is no guaranty that objects will not be removed before their expiration times as ASP.NET remove items from cache when the amount of available memory gets small. This process is called as Scavenging.

Another difference is:

The session state can be kept external (state server, SQL server) and shared between several instances of your web app (for load balancing).
This is not the case with the cache.

Tuesday, 30 October 2012

executing PL/SQL code in TOAD

DECLARE
  P_ST VARCHAR2(200);
  P_PRODUCT VARCHAR2(200);
  P_QUANTITY NUMBER;

BEGIN
  P_ST := 'WA';
  P_PRODUCT := NULL;
  P_QUANTITY := NULL;

  SP_GET_INVENTORY ( P_ST, P_PRODUCT, P_QUANTITY );
  COMMIT;
END;

Wednesday, 24 October 2012

Oracle Query to list the invalid objects and recompile the invalid objects

Query to List Invalid objects


select
owner ,object_type ,object_name from dba_objects where status != 'valid' and object_type <> 'synonym' and owner='slam' order by owner, object_type ;



 Query to recompile the invalid objects:

 
select 'alter ' || object_type || ' ' || owner || '.' || object_name || ' compile;' from dba_objects where lower(status) = 'invalid' and lower(owner)='slam';

Tuesday, 23 October 2012

Query Oracle Invalid Objects

Query Oracle Invalid objects
 
 
SELECT owner ,object_type ,object_name FROM dba_objects
WHERE status != 'VALID' order by owner, object_type ;
Recompile Oracle
SELECT 'ALTER ' || OBJECT_TYPE || ' ' || OWNER || '.' || OBJECT_NAME || ' COMPILE;'
FROM dba_objects where status = 'INVALID' and owner='SCOTT';

Savitha Shinto: converting a number to time stamp

Savitha Shinto: converting a number to time stamp: select trunc(sysdate) + 84736 / 86400 from dual

Wednesday, 14 March 2012

Oracle - to get the constraints on a table


SELECT B.COLUMN_NAME,A.CONSTRAINT_TYPE,A.TABLE_NAME,
B.CONSTRAINT_NAME ,a.*
FROM USER_CONSTRAINTS A,
USER_CONS_COLUMNS B
 WHERE A.TABLE_NAME = B.TABLE_NAME
AND lower(B.CONSTRAINT_NAME) like '%staff%' AND A.CONSTRAINT_NAME = B.CONSTRAINT_NAME and lower(r_constraint_name) like 'pk_staff%'

Oracle - to get the comments on a column

select * from user_col_comments where column_name ='STATUS_FLAG'

oracle to check the locking sessions

select
s1
||
.osuser || ' - ' || s1.MODULE || ' - ' || s1.username '@' || s1.machine || ' ( SID=' || s1.sid || ' ) is blocking '|| s2
||
.osuser || ' - ' || s2.MODULE ' - ' || s2.username || '@' || s2.machine || ' ( SID=' || s2.sid || ' ) ' AS blocking_statusfrom gv$lock l1, gv$session s1, gv$lock l2, gv$session s2where s1.sid=l1.sid and s2.sid=l2.sidand l1.BLOCK=1 and l2.request > 0
and l1.id1 = l2.id1and l2.id2 = l2.id2 ;