{"id":8460,"date":"2023-02-08T18:53:21","date_gmt":"2023-02-08T09:53:21","guid":{"rendered":"https:\/\/www.auctionpro.co.kr\/?p=8460"},"modified":"2023-02-14T16:36:47","modified_gmt":"2023-02-14T07:36:47","slug":"memory-cache-msdatashape","status":"publish","type":"post","link":"https:\/\/www.auctionpro.co.kr\/?p=8460","title":{"rendered":"Memory Cache (MSDataShape)"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\">Overview: MSDataShape  \uc774\uc6a9\ud558\uc5ec \uad00\uacc4\ud615\uc73c\ub85c Table 2\uac1c\ub97c \uce90\uc2f1\ud574\ubcf8\ub2e4.<\/h3>\n\n\n\n<h2 class=\"wp-block-heading\">1.Net Framework 4.6 \uc774\uc0c1\uc5d0\uc11c \uc124\uce58\uac00\ub2a5<\/h2>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.auctionpro.co.kr\/wp-content\/uploads\/2023\/01\/image-9.png\"><img loading=\"lazy\" decoding=\"async\" width=\"910\" height=\"577\" src=\"https:\/\/www.auctionpro.co.kr\/wp-content\/uploads\/2023\/01\/image-9.png\" alt=\"\" class=\"wp-image-8234\" srcset=\"https:\/\/www.auctionpro.co.kr\/wp-content\/uploads\/2023\/01\/image-9.png 910w, https:\/\/www.auctionpro.co.kr\/wp-content\/uploads\/2023\/01\/image-9-300x190.png 300w, https:\/\/www.auctionpro.co.kr\/wp-content\/uploads\/2023\/01\/image-9-768x487.png 768w, https:\/\/www.auctionpro.co.kr\/wp-content\/uploads\/2023\/01\/image-9-660x418.png 660w\" sizes=\"auto, (max-width: 910px) 100vw, 910px\" \/><\/a><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">2.\uc124\uce58<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">NuGet \ud328\uce90\uc9c0 \uad00\ub9ac\uc5d0\uc11c \uc124\uce58 \ubc0f \ucc38\uc870 \ucd94\uac00 \ud655\uc778<\/h3>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.auctionpro.co.kr\/wp-content\/uploads\/2023\/01\/image-8.png\"><img loading=\"lazy\" decoding=\"async\" width=\"902\" height=\"602\" src=\"https:\/\/www.auctionpro.co.kr\/wp-content\/uploads\/2023\/01\/image-8.png\" alt=\"\" class=\"wp-image-8233\" srcset=\"https:\/\/www.auctionpro.co.kr\/wp-content\/uploads\/2023\/01\/image-8.png 902w, https:\/\/www.auctionpro.co.kr\/wp-content\/uploads\/2023\/01\/image-8-300x200.png 300w, https:\/\/www.auctionpro.co.kr\/wp-content\/uploads\/2023\/01\/image-8-768x513.png 768w, https:\/\/www.auctionpro.co.kr\/wp-content\/uploads\/2023\/01\/image-8-660x440.png 660w\" sizes=\"auto, (max-width: 902px) 100vw, 902px\" \/><\/a><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">3.\ucc38\uc870 \ud655\uc778<\/h2>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.auctionpro.co.kr\/wp-content\/uploads\/2023\/01\/image-11.png\"><img loading=\"lazy\" decoding=\"async\" width=\"327\" height=\"531\" src=\"https:\/\/www.auctionpro.co.kr\/wp-content\/uploads\/2023\/01\/image-11.png\" alt=\"\" class=\"wp-image-8243\" srcset=\"https:\/\/www.auctionpro.co.kr\/wp-content\/uploads\/2023\/01\/image-11.png 327w, https:\/\/www.auctionpro.co.kr\/wp-content\/uploads\/2023\/01\/image-11-185x300.png 185w\" sizes=\"auto, (max-width: 327px) 100vw, 327px\" \/><\/a><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">4. Simple Source<\/h2>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:c# decode:true \" title=\"System.Runtime.Caching.MemoryCache\"> OleDbDataAdapter adapter = new OleDbDataAdapter(\"SHAPE {SELECT Account_ID, Account_Number, Balance FROM [Bank].[dbo].[Account]} \" +\n                            \"APPEND ({SELECT IDX, Account_ID, Amount, New_Balance, Transaction_Date FROM [Bank].[dbo].[Transaction]} AS Transaction \" +\n                            \"RELATE Account_ID TO Account_ID)\", connectionString);<\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">5. Process diagram<\/h2>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.auctionpro.co.kr\/wp-content\/uploads\/2023\/02\/image-26.png\"><img loading=\"lazy\" decoding=\"async\" width=\"594\" height=\"758\" src=\"https:\/\/www.auctionpro.co.kr\/wp-content\/uploads\/2023\/02\/image-26.png\" alt=\"\" class=\"wp-image-8461\" srcset=\"https:\/\/www.auctionpro.co.kr\/wp-content\/uploads\/2023\/02\/image-26.png 594w, https:\/\/www.auctionpro.co.kr\/wp-content\/uploads\/2023\/02\/image-26-235x300.png 235w\" sizes=\"auto, (max-width: 594px) 100vw, 594px\" \/><\/a><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">6.DB<\/h2>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.auctionpro.co.kr\/wp-content\/uploads\/2023\/02\/image-27.png\"><img loading=\"lazy\" decoding=\"async\" width=\"449\" height=\"570\" src=\"https:\/\/www.auctionpro.co.kr\/wp-content\/uploads\/2023\/02\/image-27.png\" alt=\"\" class=\"wp-image-8462\" srcset=\"https:\/\/www.auctionpro.co.kr\/wp-content\/uploads\/2023\/02\/image-27.png 449w, https:\/\/www.auctionpro.co.kr\/wp-content\/uploads\/2023\/02\/image-27-236x300.png 236w\" sizes=\"auto, (max-width: 449px) 100vw, 449px\" \/><\/a><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">7.WebService Call (DataSet)<\/h2>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.auctionpro.co.kr\/wp-content\/uploads\/2023\/02\/image-24.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"637\" src=\"https:\/\/www.auctionpro.co.kr\/wp-content\/uploads\/2023\/02\/image-24-1024x637.png\" alt=\"\" class=\"wp-image-8445\" srcset=\"https:\/\/www.auctionpro.co.kr\/wp-content\/uploads\/2023\/02\/image-24-1024x637.png 1024w, https:\/\/www.auctionpro.co.kr\/wp-content\/uploads\/2023\/02\/image-24-300x187.png 300w, https:\/\/www.auctionpro.co.kr\/wp-content\/uploads\/2023\/02\/image-24-768x478.png 768w, https:\/\/www.auctionpro.co.kr\/wp-content\/uploads\/2023\/02\/image-24-660x410.png 660w, https:\/\/www.auctionpro.co.kr\/wp-content\/uploads\/2023\/02\/image-24.png 1158w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:c# decode:true \" >using System.Web.Services;\nusing System.Data;\n \nnamespace WebService1\n{   \n    public class Service1 : System.Web.Services.WebService\n    {\n \n        [WebMethod()]\n        public DataSet GetProductCatalog()\n        {\n            \/\/ Return the complete DataSet (from the cache, if possible).         \n            \/\/return Function.GetCache();\n            return CacheClass.GetCustomerDataSet();\n        }\n \n        [WebMethod()]\n        public string[] GetProductList()\n        {\n            \/\/ Get the customer table (from the cache if possible).         \n            DataTable dt = CacheClass.GetCustomerDataSet().Tables[0];\n            \/\/ Create an array that will hold the name of each customer.         \n            string[] names = new string[dt.Rows.Count];\n            \/\/ Fill the array.         \n            int i = 0;\n \n            foreach (DataRow row in dt.Rows)\n            {\n                names[i] = row[\"FirstName\"].ToString();\n                i += 1;\n            }\n            return names;\n        }\n    }\n}<\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">8.Cache Insert (DataSet)<\/h2>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:c# decode:true \">using System;\nusing System.Data;\nusing System.Data.SqlClient;\nusing System.Runtime.Caching;\n\nnamespace WebService1\n{\n    public class CacheClass\n    {\n        private static string _key = \"Customers\";\n        private static readonly MemoryCache _cache = MemoryCache.Default;\n\n        \/\/private static string connectionString = \"Data Source=localhost;\" + \"Initial Catalog=Northwind;user ID=sa\";\n        private static string connectionString = \"Provider=MSDataShape;Data Provider=SQLOLEDB.1;Password=*******;Persist Security Info=True;User ID=MYID;Initial Catalog=MYDB;Data Source=MYCOM\";\n\n        public static DataSet GetCustomerDataSet()\n        {\nif (!(_cache.Get(_key) is DataSet ds))\n            {\n                \/\/ Recreate the item.             \n               \n                ds = new DataSet();\n\n                \/\/ Execute the command.             \n                try\n                {\n                    using (OleDbConnection conn = new OleDbConnection(connectionString))\n                    {\n                        OleDbDataAdapter adapter = new OleDbDataAdapter(\"SHAPE {SELECT Account_ID, Account_Number, Balance FROM [Bank].[dbo].[Account]} \" +\n                            \"APPEND ({SELECT IDX, Account_ID, Amount, New_Balance, Transaction_Date FROM [Bank].[dbo].[Transaction]} AS Transaction \" +\n                            \"RELATE Account_ID TO Account_ID)\", connectionString);\n\n                        \/\/conn.Open();\n                        adapter.Fill(ds, \"Accounts\");\n\n                        adapter.Dispose();\n                        conn.Close();\n                        conn.Dispose();\n                    }\n\n                    var cacheItemPolicy = new CacheItemPolicy()\n                    {\n                        \/\/Set your Cache expiration.\n                        AbsoluteExpiration = DateTime.Now.AddMinutes(60)\n                    };\n\n                    _cache.Add(_key, ds, cacheItemPolicy);\n\n                }\n                catch (Exception err)\n                {\n                    System.Diagnostics.Debug.WriteLine(err.ToString());\n                }\n\n            }\n            return _cache.Get(_key) as DataSet;\n        }\n\n    }\n}<\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">9.\ub514\ubc84\uadf8 ds<\/h2>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.auctionpro.co.kr\/wp-content\/uploads\/2023\/02\/image-29.png\"><img loading=\"lazy\" decoding=\"async\" width=\"820\" height=\"342\" src=\"https:\/\/www.auctionpro.co.kr\/wp-content\/uploads\/2023\/02\/image-29.png\" alt=\"\" class=\"wp-image-8464\" srcset=\"https:\/\/www.auctionpro.co.kr\/wp-content\/uploads\/2023\/02\/image-29.png 820w, https:\/\/www.auctionpro.co.kr\/wp-content\/uploads\/2023\/02\/image-29-300x125.png 300w, https:\/\/www.auctionpro.co.kr\/wp-content\/uploads\/2023\/02\/image-29-768x320.png 768w, https:\/\/www.auctionpro.co.kr\/wp-content\/uploads\/2023\/02\/image-29-660x275.png 660w\" sizes=\"auto, (max-width: 820px) 100vw, 820px\" \/><\/a><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">10.\ud654\uba74<\/h2>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.auctionpro.co.kr\/wp-content\/uploads\/2023\/01\/image-7.png\"><img loading=\"lazy\" decoding=\"async\" width=\"527\" height=\"177\" src=\"https:\/\/www.auctionpro.co.kr\/wp-content\/uploads\/2023\/01\/image-7.png\" alt=\"\" class=\"wp-image-8220\" srcset=\"https:\/\/www.auctionpro.co.kr\/wp-content\/uploads\/2023\/01\/image-7.png 527w, https:\/\/www.auctionpro.co.kr\/wp-content\/uploads\/2023\/01\/image-7-300x101.png 300w\" sizes=\"auto, (max-width: 527px) 100vw, 527px\" \/><\/a><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">11.Result<\/h2>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.auctionpro.co.kr\/wp-content\/uploads\/2023\/02\/image-28.png\"><img loading=\"lazy\" decoding=\"async\" width=\"875\" height=\"688\" src=\"https:\/\/www.auctionpro.co.kr\/wp-content\/uploads\/2023\/02\/image-28.png\" alt=\"\" class=\"wp-image-8463\" srcset=\"https:\/\/www.auctionpro.co.kr\/wp-content\/uploads\/2023\/02\/image-28.png 875w, https:\/\/www.auctionpro.co.kr\/wp-content\/uploads\/2023\/02\/image-28-300x236.png 300w, https:\/\/www.auctionpro.co.kr\/wp-content\/uploads\/2023\/02\/image-28-768x604.png 768w, https:\/\/www.auctionpro.co.kr\/wp-content\/uploads\/2023\/02\/image-28-660x519.png 660w\" sizes=\"auto, (max-width: 875px) 100vw, 875px\" \/><\/a><\/figure>\n","protected":false},"excerpt":{"rendered":"<div class=\"mh-excerpt\"><p>Overview: MSDataShape \uc774\uc6a9\ud558\uc5ec \uad00\uacc4\ud615\uc73c\ub85c Table 2\uac1c\ub97c \uce90\uc2f1\ud574\ubcf8\ub2e4. 1.Net Framework 4.6 \uc774\uc0c1\uc5d0\uc11c \uc124\uce58\uac00\ub2a5 2.\uc124\uce58 NuGet \ud328\uce90\uc9c0 \uad00\ub9ac\uc5d0\uc11c \uc124\uce58 \ubc0f \ucc38\uc870 \ucd94\uac00 \ud655\uc778 3.\ucc38\uc870 \ud655\uc778 4. Simple <a class=\"mh-excerpt-more\" href=\"https:\/\/www.auctionpro.co.kr\/?p=8460\" title=\"Memory Cache (MSDataShape)\">[&#8230;]<\/a><\/p>\n<\/div>","protected":false},"author":6,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[237],"tags":[],"class_list":["post-8460","post","type-post","status-publish","format-standard","hentry","category-memory-cache"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.auctionpro.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/8460","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.auctionpro.co.kr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.auctionpro.co.kr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.auctionpro.co.kr\/index.php?rest_route=\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/www.auctionpro.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=8460"}],"version-history":[{"count":0,"href":"https:\/\/www.auctionpro.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/8460\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.auctionpro.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=8460"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.auctionpro.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=8460"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.auctionpro.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=8460"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}